java - Do you have to go through all lines in .json with gson? -


I'm just starting with Jason Parsing and writing, and I'm using GSN to do this. Let's say that you have to iterate through each line in the json file, do I want to use some of the bottom of the file, to get to the line?

Without jumping through Alice, do you have everything Bob? Now I just know how to start the open object (), (), open Bob, go through them, then close Bob, then go to Alice. As

  { "Bob": { "following": [215876567, 64044676, 276716878, 208675951, 151503222,], "followers" [720567433, 1005407395, 2432297370, 2463742694, 2463741222, 51101660, 2463700218, 2463741192, 405107240,]}, "Alice": { "location": "New York"}}    

You can get Direct Alice below

  JsonParserjsonParser = new JsonParser (); Jason Element Jason Element = Jason Pearce. PRSE (YOUR_JSON_STRING_HERE);   

// get the JsonElement Alice such as

  JsonElement aliceJsonElement = jsonElement.getAsJsonObject () ( "Alice") .;   

You will give this json object {"location": "new york"}

in the end you will have it as

  GSON GSN = new GSON (); Type type type & lt; Maps & lt; String, string & gt; & Gt; () {} GetType (); Maps & lt; String, string & gt; Map = GSN.fr Jason (Alisonson Element, map type);   

// re-map

This way you can get Bob and following

  jsonElement.getAsJsonObject (). ") Meets jsonElement.getAsJsonObject (). (" Get Bob "). GetAsJsonObject (). (" Low ")    

Comments

Popular posts from this blog

python - how we can use ajax() in views.py in django? -

matlab - Using loops to get multiple values into a cell -

python - Sequence Pattern recognition with Pybrain -