java - Parsing a JSON array BEGIN_ARRAY but was NAME -
I am parsing this JSON stream
{"status": "ok "," Count ": 1," Data ": {" "1000194290": [{"Stats": {"Victory": 472, "All": {"Spotless": 0, "Hit": 0, "War_Aug_GP "," Lights ": 0," HitParents ": 0," Damaged "," 0 "," Damage ": 0," Caption_point ": 0," Action ": 894, Shots": 0, XP ": 0," Fraggs ": 0," Saved_Battles ": 0," Dropped CAPAPRPUs ": 0}," Action ": 894}
I started an array at 1000194290 But try to do it The key is
code> exception "in the thread" main "java.lang.IllegalStateException: expected BEGIN_ARRAY but the row 1 was named on column 35
My parsing class looks like this
Public list & amp;; Tankstats & gt; ReadJsonStream (InputStream in) throws IOException {try (JsonReader Reader = New JsonReader (New InputStreamReader (in "UTF-8"))) Read {readTankIdStep (Reader); }} Public List & amp;; Tankstats & gt; ReadTankIdStep (JSReader Reader) throws IOException {list & lt; Tankstats & gt; Users = New Arrestists & lt; & Gt; (); Reader.beginObject (); While (reader.hasNext ()) {string name = reader.exnet (); If (name.equals ("data")) {reader.beginObject (); While (reader.hasNext ()) {reader.beginArray (); While (reader.hasNext ()) {users.add (readTankId (Reader)); } Reader.endArray (); }} Other {reader.skipValue (); }} Reader.endObject (); Return user; }
I'm not sure how to complete this error.
You can check for JSON
"data": {< with if (name is equal to ("data")) {
then the value of that name In the pair
use the object with reader.beginObject ();
But then you do this
while (reader.hasNext ()) {reader.beginArray ();
While the reader has a token
"1000194290": [[
You must use the first Before you use the array.
Comments
Post a Comment