I'm using JSON-lib to parse an object and read a string from it. This works fine for a valid string but it can also be null. For example:
JSONObject jsonObject = JSONObject.fromObject("{\"foo\":null}");
String str = jsonObject.getString("foo");
In this case I would expect str to be null but it is instead "null". Calling any other method seems to throw an error. Is there anyway to have JSONLib parse a string if the value is a string but return null if the value is null?
.getString(), which returns aString, and you expected something other than a string?