我希望能够在Java操作方法中访问JSON字符串中的属性.只需说出字符串即可myJsonString = object.getJson().下面是字符串的示例:
{
'title': 'ComputingandInformationsystems',
'id': 1,
'children': 'true',
'groups': [{
'title': 'LeveloneCIS',
'id': 2,
'children': 'true',
'groups': [{
'title': 'IntroToComputingandInternet',
'id': 3,
'children': 'false',
'groups': []
}]
}]
}
Run Code Online (Sandbox Code Playgroud)
在此字符串中,每个JSON对象都包含其他JSON对象的数组.目的是提取ID列表,其中任何给定对象拥有包含其他JSON对象的组属性.我把Google的Gson视为潜在的JSON插件.任何人都可以提供某种形式的指导,告诉我如何从这个JSON字符串生成Java?
我有JSON对象如下:
member = "{interests : [{interestKey:Dogs}, {interestKey:Cats}]}";
Run Code Online (Sandbox Code Playgroud)
在Java中,我想解析上面的json对象并将值存储在arraylist中.
我正在寻找一些代码,通过它我可以实现这一点.
我正在开发一个包含java文件和php文件的应用程序.java文件调用php文件,这些文件在ddbb中执行查询并将结果作为数组php返回,但是将其打印在屏幕上.我把它作为一个字符串在java中,我必须将它转换为数组或集合,但我不知道如何做到这一点.
php打印结果的一个例子是:
Array
(
[0] => Array
(
[id] => 1
[0] => 1
[name] => pepe
[1] => pepe
)
[1] => Array
(
[id] => 2
[0] => 2
[name] => antoñito
[1] => antoñito
)
[2] => Array
(
[id] => 3
[0] => 3
[name] => loló
[1] => loló
)
[3] => Array
(
[id] => 4
[0] => 4
[name] => ñoño
[1] => ñoño
)
[4] => Array
(
[id] => 5
[0] …Run Code Online (Sandbox Code Playgroud)