我希望能够在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?
如何让Jackson的build()方法完美打印其JSON输出?这是一个漂亮打印丑陋形式的JSON代码的示例.我需要使用JSON代码的漂亮版本然后将其转移到丑陋的fom.怎么做到呢?我需要转换这个:
{
"one" : "AAA",
"two" : [ "BBB", "CCC" ],
"three" : {
"four" : "DDD",
"five" : [ "EEE", "FFF" ]
}
}
Run Code Online (Sandbox Code Playgroud)
对此:
{"one":"AAA","two":["BBB","CCC"],"three":{"four":"DDD","five":["EEE","FFF"]}}
Run Code Online (Sandbox Code Playgroud)
我试图删除'\n','\ t'和''字符; 但是值中可能有一些这样的字符,所以我不能这样做.还有什么可以做的?