2

This source Google Finance option Chain Data returns the relaxed JSON, I wasn't able to Parse this JSON through PDI (Pentaho Data Integratio) (originally required) So thought of Parsing it in Java Code.

I tried using ObjectMapper and its Feature to allow unquoted field names but the json returned from above source is totally relaxed and can miss quotes anywhere.

String json = "{name:\"ankit\"}";
Map<String,String> map = new HashMap<String,String>();
ObjectMapper mapper = new ObjectMapper();
mapper.configure(org.codehaus.jackson.JsonParser.Feature.ALLOW_UNQUOTED_FIELD_NAMES, true);
map = mapper.readValue(json,new TypeReference<HashMap<String,String>>(){});
System.out.println(map);

It works fine if the keys in JSON are unquoted but fails if the same goes with values.

Is there any way out doing it with Pentaho Data integration or in Java Class.

ankit arora
  • 89
  • 15

0 Answers0