Search Unity

  1. Unity Asset Manager is now available in public beta. Try it out now and join the conversation here in the forums.
    Dismiss Notice

json library for webgl

Discussion in 'Unity 5 Pre-order Beta' started by dylan.ryan, Nov 25, 2014.

  1. dylan.ryan

    dylan.ryan

    Joined:
    Oct 15, 2012
    Posts:
    29
    Hello, I was wondering if anyone has successfully used any JSON mapping libraries on the webgl player. Our app makes heavy use of restful services and we need a fairly robust JSON library.

    I have tried both JsonFX, and LitJson(missing complex mapping functionality) so far and I have not been successful, as they cause runtime errors.


    Thank you,
    Dylan
     
  2. Dustin-Horne

    Dustin-Horne

    Joined:
    Apr 4, 2013
    Posts:
    4,568
    Dylan -

    I have been working on getting JSON .NET compatible with WebGL. I'll be doing some testing this evening and I can let you know how it goes. WebGL is still very much a beta product so compatibility may fluctuate.
     
  3. LaughingGull

    LaughingGull

    Joined:
    Jul 8, 2012
    Posts:
    37
    I am also very interested in this, trying to get JSON data to come in but same thing, crashing.

    Jason
     
  4. Dustin-Horne

    Dustin-Horne

    Joined:
    Apr 4, 2013
    Posts:
    4,568
    I posted this in my official release thread but I have been working to get compatibility with WebGL. I have managed to get some serialization and deserialization working but there is still a ways to go.
     
  5. LaughingGull

    LaughingGull

    Joined:
    Jul 8, 2012
    Posts:
    37
    Do you by chance have an timeframe for when you think you'll have it compatible? Thanks!
     
  6. rakkarage

    rakkarage

    Joined:
    Feb 3, 2014
    Posts:
    683
  7. Dustin-Horne

    Dustin-Horne

    Joined:
    Apr 4, 2013
    Posts:
    4,568
    Not as of yet because it is dependent on Unity bug fixes in IL2CPP
     
  8. samuelmorais

    samuelmorais

    Joined:
    Aug 3, 2012
    Posts:
    62
    I have used "Json Magic!" from asset store in my webgl project.
    You need to rewrite the classes you want to be serialized and have more work, but at least it works.
    The only type I didn't manage to serialize was Dictionary, but I used LgJsonArray instead.
     
  9. Dustin-Horne

    Dustin-Horne

    Joined:
    Apr 4, 2013
    Posts:
    4,568
    Good to know. JSON .NET is now working with IL2CPP at least for 64-bit iOS builds and it should be coming in a very near beta so it should be able to support WebPlayer as well.
     
  10. muzzythom

    muzzythom

    Joined:
    Dec 1, 2014
    Posts:
    17
    SimpleJSON (available at https://github.com/facebook-csharp-sdk/simple-json/tree/master/src/SimpleJson) seems to work well. I've been using it with the WebGL export, with no bugs (at least, none caused by SimpleJson!). It's also easy to integrate (as it's a single file), has a straightforward API, and is permissively licensed.

    That said, my usage of it is somewhat limited. I don't know the structure of my data, so I haven't used its reflection capabilities (instead serializing to JsonObjects). I did test them when evaluating the library though, and they seemed to work.