r17033
Example script:
Output:
This is malformed JSON, as verified by a JSON validator. The initial backslash needs to be escaped:
I believe the fault to be in Value.java, in toJSON():
It correctly escapes the quotation mark (as seen above) but not \. Maybe change to:
Example script:
Code:
void main()
{
string input_string = "\\=\"";
string [int] output_map;
output_map[0] = input_string;
output_map[1] = get_campground().to_json(); //to verify nested JSON
string json = output_map.to_json();
print_html(json);
}
Code:
{ "0" : "\=\"", "1" : "{ \"Certificate of Participation\" : 1, \"Dramatic™ range\" : 1, \"Queue Du Coq cocktailcrafting kit\" : 1, \"chef-in-the-box\" : 1, \"bartender-in-the-box\" : 1, \"pagoda plans\" : 1, \"Frobozz Real-Estate Company Instant House (TM)\" : 1, \"clockwork maid\" : 1, \"Discount Telescope Warehouse gift certificate\" : 1, \"ice harvest\" : 6, \"portable Mayo Clinic\" : 1, \"potted tea tree\" : 1, \"haunted doghouse\" : 1, \"Witchess Set\" : 1, \"Source terminal\" : 1 }" }
Code:
{ "0" : "\\=\"", "1" : "{ \"Certificate of Participation\" : 1, \"Dramatic™ range\" : 1, \"Queue Du Coq cocktailcrafting kit\" : 1, \"chef-in-the-box\" : 1, \"bartender-in-the-box\" : 1, \"pagoda plans\" : 1, \"Frobozz Real-Estate Company Instant House (TM)\" : 1, \"clockwork maid\" : 1, \"Discount Telescope Warehouse gift certificate\" : 1, \"ice harvest\" : 6, \"portable Mayo Clinic\" : 1, \"potted tea tree\" : 1, \"haunted doghouse\" : 1, \"Witchess Set\" : 1, \"Source terminal\" : 1 }" }
I believe the fault to be in Value.java, in toJSON():
Code:
return "\"" + StringUtilities.globalStringReplace( this.toString(), "\"", "\\\"" ) + "\"";
Code:
return "\"" + StringUtilities.globalStringReplace(StringUtilities.globalStringReplace( this.toString(), "\\", "\\\\"), "\"", "\\\"") + "\"";