我正在使用json简单来创建和解析一些json。但是,在创建它之后,我会在ParseException
时获得parser.parse(jStr);
。以下是jStr
{"score":12,"balls":[[PURPLE_V,134.33325,331.11713,2.0,10.750022,-115,11.0,0],[PURPLE_SPLAT,59.209473,169.87143,0.0,6.2909174,16,11.0,1],[GREEN_V,119.00015,73.71671,-12.0,6.7500067,-35,11.0,0],[ORANGE_V,229.66664,7.4416676,8.0,5.250001,-5,11.0,0]]}
这有什么问题?我可以不做数组数组吗?
答案 0 :(得分:6)
PURPLE_V
,PURPLE_SPLAT
,GREEN_V
,ORANGE_V
应在引号内。
答案 1 :(得分:2)
尝试JSONLint:
{
"score": 12,
"balls": [
[
PURPLE_V,
134.33325,
// ..
<强>输出强>
Parse error on line 4:
... [ PURPLE_V,
----------------------^
Expecting 'STRING', 'NUMBER', 'NULL', 'TRUE', 'FALSE', '{', '[', ']'
PURPLE_V
等不是可识别的类型。 如果你想让它们成为字符串,请用引号括起来。
答案 2 :(得分:1)
非数字值应介于引号之间。
{"score":12,"balls":[["PURPLE_V",134.33325,331.11713,2.0,10.750022,-115,11.0,0],["PURPLE_SPLAT",59.209473,169.87143,0.0,6.2909174,16,11.0,1],["GREEN_V",119.00015,73.71671,-12.0,6.7500067,-35,11.0,0],["ORANGE_V",229.66664,7.4416676,8.0,5.250001,-5,11.0,0]]}
我建议您使用http://jsonlint.com/来验证您的JSON。您可能还想查看http://www.json.org/
答案 3 :(得分:1)
已更正(还有一些格式供查看):
{"score":12,"balls":[
["PURPLE_V",134.33325,331.11713,2.0,10.750022,-115,11.0,0],
["PURPLE_SPLAT",59.209473,169.87143,0.0,6.2909174,16,11.0,1],
["GREEN_V",119.00015,73.71671,-12.0,6.7500067,-35,11.0,0],
["ORANGE_V",229.66664,7.4416676,8.0,5.250001,-5,11.0,0]
]}