gwt - Why JSONParser doesn't remove the " from keys and values? -


i have following json-string:

{"locale":"de","strings":[{"key":"navigation.search","value":"suchen"}]} 

i try parse way:

// parse response text json string json = response.gettext(); window.alert(json); jsonvalue jsonvalue = jsonparser.parselenient("{\"locale\":\"de\",\"strings\":[{\"key\":\"navigation.search\",\"value\":\"suchen\"}]}"); window.alert(jsonvalue.isobject().get("locale").tostring()); jsonarray jsonarray = jsonvalue.isobject().get("strings").isarray(); (int = 0; < jsonarray.size(); i++) {     window.alert(jsonarray.get(i).isobject().get("key").isstring() + " -> " + jsonarray.get(i).isobject().get("value").isstring()); } 

why there quotes in window.alert(), thought, quotes essential, creating json.

by way, json created json.org java-classes:

printwriter w = new printwriter(system.err); new jsonwriter(w)      .object()           .key("locale").value("de").key("strings").array().object().key("key").value("navigation.search").key("value").value("suchen").endobject().endarray()      .endobject(); w.flush(); 

i think key use stringvalue method. try:

jsonarray.get(i).isobject().get("value").isstring().stringvalue()


Comments

Popular posts from this blog

c# - how to write client side events functions for the combobox items -

exception - Python, pyPdf OCR error: pyPdf.utils.PdfReadError: EOF marker not found -