Scenario :
I am using following code to decode a JSON String to generate the objects using it.
{"av":{"tid":"1000","sslist":[{"ss":{"ssId":"1","ssName":"Test ss "name one"}},{"ss":{"ssId":"2","ssName":"Test ss name two"}}],"hl":{"lc":0}}}
Now, I have hundreds elements of sslist
and all are failed because of one bloody "
in ssName
in the first ss
element.
But this error is throwing when the String is parsing at the very beginning at the createJsonParser() method.
Question :
I want to ignore the error prone node only and proceed with other hundred of correct nodes. Is there any other method to do this?
Code :
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.core.JsonFactory;
import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.databind.JsonNode;
public class JsonReader {
private void readJsonMethodThree(String jsonString) throws JsonParseException, IOException{
ObjectMapper mapper = new ObjectMapper();
JsonFactory factory = mapper.getJsonFactory();
JsonParser jsonParser = factory.createJsonParser(jsonString);
JsonNode jsonNode = mapper.readTree(jsonParser);
}
}
Exception :
Exception in thread "main" com.fasterxml.jackson.core.JsonParseException: Unexpected character ('n' (code 110)): was expecting comma to separate OBJECT entries
at [Source: java.io.StringReader@12cc95d; line: 1, column: 69]