[英]Parsing an "array" string JSON with JAVA
I have data coming from a websocket in JSON format.我有来自 JSON 格式的 websocket 的数据。
{"Type":112,"F":[1,2,3974.909912109375,27500,1639207185]}
Im parsing it like this...我是这样解析的...
obj = new JSONObject(text);
Object o = obj.get("F");
System.out.println(o);
Which gives me...这给了我...
[1,2,3974.909912109375,27500,1639207185]
In the console.在控制台中。
My question is, is this a string or an object or what is it?我的问题是,这是一个字符串还是一个 object 或者它是什么? I can't seem to access the indexes.
我似乎无法访问索引。
o.get(0);
If I try to cast it to a string, my program crashes???如果我尝试将其转换为字符串,我的程序会崩溃???
String s = (String) o;
So I have no idea what this is?所以我不知道这是什么? And how to access the data in it.
以及如何访问其中的数据。 Any ideas??
有任何想法吗?? As to what this actually is??
至于这究竟是什么?? Is it just an Array??
它只是一个数组吗? I feel like its simply a string, but its not???
我觉得它只是一个字符串,但它不是???
I simply what to read the values....ie我只是读什么值....即
o[0] = 1; o[3] = 27500
Figured it out...弄清楚了...
obj = new JSONObject(text);
JSONArray jArr = (JSONArray) obj.get("F");
Then I can do那我可以做
jArr.get(0); etc...
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.