I have 2 JSON-encoded strings that are identical in structure, but one string returns an error on parsing, and the other parses just fine. (This happens in both java and PHP.)
PHP actually doesn't return anything, not even an error, just null (this is with "error_reporting = E_ALL" set in php.ini)
Java on the other hand, did throw an exception, which is described just above the Java code.
I can't understand what could possibly be breaking as these are nearly identical, with exception to the values, but even the values' types are identical (int, string, etc);
Thanks,
Here are the strings in plaintext:*
WORKING STRING:*
{"id":40119,"name":"3Solid Majestic Zircon","level":80,"slot":0,"source":[1],"sourcemore":[{"t":6,"ti":66497,"n":"Solid Majestic Zircon","s":755,"c":11}],"classs":3,"subclass":1}
NONWORKING STRING*
{"id":41266,"name":"4Skyflare Diamond","level":80,"slot":0,"source":[1],"sourcemore":[{"t":6,"ti":57425,"n":""Transmute": Skyflare Diamond","s":171,"c":11}],"classs":3,"subclass":6}
Code Examples:*
PHP: using the default json_decode() function
+JAVA: using the JSON-SIMPLE package for the java decode [ json_parser() ]+
JAVA CODE:*
if you change inputstring from "goodstring" to" badstring", returns:
.....+Exception in thread "main" java.lang.Error: Lexical Error: Unmatched Input.+
.............+at json.simple.parser.Yylex.yylex(Yylex.java:295)+
.............+at json.simple.parser.JSONParser.parse(JSONParser.java:41)+
.............+at wowgemsdb.test.main(test.java:28)+
Note: test.java LINE 28 is the line with:
String result = json_parser.parse(new BufferedReader(new StringReader(inputstring))).toString();
//******************BEGIN JAVA CODE******************//
JSONParser json_parser = new JSONParser();
String goodstring = "{\"id\":40119,\"name\":\"3Solid Majestic Zircon\",\"level\":80,\"slot\":0,\"source\":[1],\"sourcemore\":[{\"t\":6,\"ti\":66497,\"n\":\"Solid Majestic Zircon\",\"s\":755,\"c\":11}],\"classs\":3,\"subclass\":1}";
String badstring = "{\"id\":41266,\"name\":\"4Skyflare Diamond\",\"level\":80,\"slot\":0,\"source\":[1],\"sourcemore\":[{\"t\":6,\"ti\":57425,\"n\":\"\"Transmute\": Skyflare Diamond\",\"s\":171,\"c\":11}],\"classs\":3,\"subclass\":6}";
try{
String inputstring = goodstring; //which JSON-encoded string to parse
String result = json_parser.parse(new BufferedReader(new StringReader(inputstring))).toString();
System.out.println(result);
} catch(Exception e){}
//******************END JAVA CODE******************//
PHP CODE:+
//*******************BEGIN PHP CODE*******************//
$goodString = '{"id":40119,"name":"3Solid Majestic Zircon","level":80,"slot":0,"source":[1],"sourcemore":[{"t":6,"ti":66497,"n":"Solid Majestic Zircon","s":755,"c":11}],"classs":3,"subclass":1}';
$badString = '{"id":40119,"name":"3Solid Majestic Zircon","level":80,"slot":0,"source":[1],"sourcemore":[{"t":6,"ti":66497,"n":"Solid Majestic Zircon","s":755,"c":11}],"classs":3,"subclass":1}';
json_decode($goodString); //THIS WORKS
json_decode($badString); // THIS RETURNS NOTHING (doesn't even give an error)
//*******************END PHP CODE*******************//