Inconsistent decoding of function-like strings
Brought to you by:
aalmiray
json-lib inconsistently decodes function-like strings:
JSONObject.fromObject("{\"foo\":\"function() {return 0;}\"}")
-> {"foo":"\"function() {return 0;}\""}
and
JSONObject.fromObject("{\"foo\": \"function() {return 0;}\"}")
-> {"foo":function(){ return 0; }}
In the first instance, there are extra quotes in the resulting string.
In the second, which differs by having a space after the colon, the string has been treated as a function.
As it happens, I just want the value to remain a normal string -- i.e., neither of those -- but JSONObject.getString() does give me what I want in the second case. The trouble is that I don't control whether there is a space after the colon or not.