How can JavaScript be made to parse the following JavaScript object?
{// This is a comment x: '1', y: {z: '2'}}
Note that the above example object Not a real JSON - it's a JavaScript object that does not have quotes (1) around the attribute name, (2) uses singles, not double, quotation around value, and (3) a comment.
Use the case: I need to parse a javascript object that is embedded in HTML I can get JavaScript myself, but now I have to parse it.
You can try something with:
Private static Final ObjectMapper om = New ObjectMapper (); Om.configure (JSONERATOR.Feature. ALLOW_SINGLE_QUOTES, is true); Om.configure (JsonParser.Feature.ALLOW_UNQUOTED_FIELD_NAMES, true); Om.configure (JsonParser.Feature.ALLOW_COMMENTS, true);
Comments
Post a Comment