JSON and the Quoted Strings
“Bug” number two for today is a little more tricky.
I was retrieving a JSON object in the GWT (Google Web Toolkit) and putting its Java representation in a HashMap. The only problem is that I could never find it again by referring to its key which I also extracted from JSON object. Here is why:
currentCons.get("URI").isString().toString()
Is actually not returning the String representation of a JSONString object but the quoted representation of that String: e.g. “key” and not key. It was in the API but it took me a while to figure it out…
The solution is:
currentCons.get("URI").isString().stringValue();
Which gets what I wanted, i.e. the String representation without the quotes.