Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

LitJson and iOS

Discussion in 'iOS and tvOS' started by poolts, Jan 22, 2014.

  1. poolts

    poolts

    Joined:
    Aug 9, 2012
    Posts:
    113
    Has anyone got LitJson working in iOS?

    Code (csharp):
    1. InvalidOperationException: JsonData instance doesn't hold a long
    2.  at LitJson.JsonData.LitJson.IJsonWrapper.GetLong () [0x00000] in <filename unknown>:0
    3.  at LitJson.JsonData.WriteJson (IJsonWrapper obj, LitJson.JsonWriter writer) [0x00000] in <filename unknown>:0
    I'm getting this error. After doing some research it seems like the problem is between JIT and AOT.

    So is it just a case of iOS not wanting to play nice with LitJson? Or something within my code?
     
  2. Dustin-Horne

    Dustin-Horne

    Joined:
    Apr 4, 2013
    Posts:
    4,568
    I'm not seeing an AOT error there. Could you show us the raw JSON text you're trying to deserialize? My guess is that whatever it's trying to convert in the JSON data can't be cast to type "long". I'm not sure if ListJson works properly on iOS. That's part of the reason I ported JSON .NET. I think JsonFX works for the most part, depending on what you're trying to serialize / deserialize and there's also JsonObject which is free on the asset store, though it's a little more of a manual process.
     
  3. poolts

    poolts

    Joined:
    Aug 9, 2012
    Posts:
    113
    I bought JSON. NET, but I was looking for something with a generic JSON object already set up.

    So you could do things like data["key"] returns base value type.
     
  4. Dustin-Horne

    Dustin-Horne

    Joined:
    Apr 4, 2013
    Posts:
    4,568
    Poolts,

    Have you looked at the JArray and JObject classes that are part of JSON .NET? They allow you to do the same thing and since you've already purchased it you might as well leverage it.