How to parse following json in java so that I will get two objects and I can iterate over them? -
this question has answer here:
- how parse json 29 answers
in below json, there 2 arrays. want them parsed in such way can iterate on them 1 one , store result.
please find below content of json file.
{ "id": 1, "firstname": "katerina", "languages": [ { "lang": "en", "knowledge": "proficient" }, { "lang": "fr", "knowledge": "advanced" } ], "job": { "site": "www.javacodegeeks.com", "name": "java code geeks" } } { "id": 2, "firstname": "kati", "languages": [ { "lang": "fr", "knowledge": "average" }, { "lang": "hn", "knowledge": "advanced" } ], "job": { "site": "www.example.com", "name": "php code geeks" } }
your json not valid looks first block copied create next block. anyway using java can use jsonprovider(part of jaxrs library) , use convert java object json or json java object. can use gson libabry google, add jar in library or use maven dependency if using maven
<dependency> <groupid>com.google.code.gson</groupid> <artifactid>gson</artifactid> <version>2.2.4</version>
here example of gson http://www.javacreed.com/simple-gson-example/