Well two for right now:
Json.net IS a one time buy, right?
While using the Boomlagoon json object code, I encountered a curious bug. I sent that exact JSON object described above, but the first several times it decoded as having only 3 fields (missing the second boolean).
here is the code looping it:
JSONObject derp = JSONObject.Parse(download.text);
foreach (KeyValuePair<string, JSONValue> pair in derp)
{
Debug.Log("key : value -> " + pair.Key + " : " + pair.Value);
//Each JSONValue has a JSONValueType that tells you what type of value it is. Valid values are: String, Number, Object, Array, Boolean or Null.
Debug.Log("pair.Value.Type.ToString() -> " + pair.Value.Type.ToString());
//if (pair.Value.Type == JSONValueType.Number)
//{
// //You can access values with the properties Str, Number, Obj, Array and Boolean
// Debug.Log("Value is a number: " + pair.Value.Number);
//}
}
I'm positive my debug log was printing that it only looped through 3 fields and missed the second boolean field each time. I did however all fields listed in the string being sent to my server. It began to pickup all the fields AFTER I added a little code to check for it existing derp:
if (derp.ContainsKey("ShouldDisplayMessage"))
{
Debug.Log("FOUND FIRST!");
}
if (derp.ContainsKey("WasQuerySuccess"))
{
Debug.Log("FOUND SECOND!");
}
So I placed that above the loop and suddenly the loop could find everything.... Then I commented the derp.contains check back out and it still works.
What could cause this line of code:
JSONObject derp = JSONObject.Parse(download.text);
To randomly fail and skip over an object's field? I'm not sure if this boomlagoon code is unstable now because all fields were positively in the string, and I never changed serverside PHP code.