What is my best option for decoding JSON objects sent by my PHP server?

Well two for right now:

  1. Json.net IS a one time buy, right?

  2. 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.

/r/Unity3D Thread Parent