1

i got problems when i try to parse json with ObjectMapper and in the json there is an number that look like mate

json

{ "_id" : 290365351583, "my_number" : 1.5638694276102368E8 }

my code

ObjectMapper objectMapper= new ObjectMapper();
DBobject obj = ;\\the json when i select it from mongo db
String data = JSONSerializers.getStrict().serialize(obj);
JsonNode = objectMapper.readTree(data);

when i run this code i got ERROR "Non-standart token 'Infinity': enable JsonParser.Feature.ALLOW_NON_NUMERIC_NUMBERS to allow"

2
  • Did you try enabling JsonParser.Feature.ALLOW_NON_NUMERIC_NUMBERS ? Commented May 19, 2016 at 13:23
  • I think it's unable to parse the decimal in my_number value. Commented May 19, 2016 at 15:19

1 Answer 1

1

You can use this maven dependency : http://mvnrepository.com/artifact/org.json/json/20160212

It's very simple to understated and use. ex:

JSONObject obj = "YOUR_JSON_STRING";
String result = obj.getString("YOUR_STRING_KEY");

There you can use alot of methods like: getInt(), getDouble(), getBoolean() etc.

Useful examples are there : http://crunchify.com/java-how-to-parse-jsonobject-and-jsonarrays/

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.