Answer the question
In order to leave comments, you need to log in
How to parse this JSON string?
There is a line like this:
[
{
"email": "[email protected]",
"primary": true,
"verified": true,
"visibility": "private"
}
]
Answer the question
In order to leave comments, you need to log in
looked at the code - no errors found. the problem was with imported org.json.jso.jar -
I'm trying to parse it using the json.org library
Java
- json-java
- JSONUtil
- jsonp
- json-lib
- Stringtree
- SOJO
- json-taglib
- flexjson
- Argo
- jsonij
- fast json
- mjson
- jjson
- json-simple
- json-io
- google-gson
- FOSS Nova JSON
- Corn CONVERTER
- Apache johnzon
- Genson
- cookjson
- progbase
- jackson
- MOXy
public class Something {
public String email;
public boolean primary;
public boolean verified;
public String visibility;
}
// import com.fasterxml.jackson.databind.ObjectMapper; // version 2.11.1
// import com.fasterxml.jackson.annotation.JsonProperty; // version 2.11.1
ObjectMapper om = new ObjectMapper();
Something[] root = om.readValue(jsonString, Something[].class);
//import com.google.gson.Gson;
Gson gson = new Gson();
Something[] data = gson.fromJson(jsonString, Something[].class);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question