I have String variable called jsonString
:
{\"phonetype\":\"N95\",\"cat\":\"WP\"}
Now I want to convert it into JSON Object. I
String to JSON using Jackson
with com.fasterxml.jackson.databind
:
Assuming your json-string represents as this: jsonString = {"phonetype":"N95","cat":"WP"}
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
/**
* Simple code exmpl
*/
ObjectMapper mapper = new ObjectMapper();
JsonNode node = mapper.readTree(jsonString);
String phoneType = node.get("phonetype").asText();
String cat = node.get("cat").asText();