JSON for saving ships

March 31st, 2010| Posted by Andy Korth
Categories: Uncategorized | Tags:

It’s been mostly backend work for me, lately. I’ve evaluated a few different JSON libraries- the plan is to use it to create strings of our complex data types to save within Unity’s PlayerPrefs system.

First I tried JSON Sharp, and I got embarrassingly far into it before realizing the library didn’t come with a parser to turn the JSON strings back into anything. I then looked at JSON.NET but found it to be huge, heavyweight, and had some dependencies in System.LINQ that Unity did not include. So rather than mess with it, I went to find a lightweight library and found LitJSON, which seems pretty good.

So I’ve got the ships saving in a rough fashion. Loading will be a bit more tricky.

Meanwhile, Scott’s been working on some more HUD stuff, and clicking to select things!

  1. James McNeill
    March 31st, 2010 at 20:54
    Reply | Quote | #1

    JSON seems like a really sensible format. I’ve been messing with JSON parsers a bit this past week when I should have been working on other things. I’ve never been jazzed about XML; I think JSON would be a better fit for the kinds of things I end up doing.

  2. Andy Korth
    April 1st, 2010 at 08:45
    Reply | Quote | #2

    Yeah, XML is about as long-winded as I could ever imagine. I was just happy to find a lightweight solution. Once you format the JSON string, it’s fairly readable:

    "componentName":"Hull Component",
    "componentName":"Cockpit A",
    "componentName":"Thorium Engine",

  3. Andy Korth
    April 1st, 2010 at 08:46
    Reply | Quote | #3

    Except when wordpress removes the indentation…

Comments are closed.