Search Unity

  1. Calling all beginners! Join the FPS Beginners Mods Challenge until December 13.
    Dismiss Notice
  2. It's Cyber Week at the Asset Store!
    Dismiss Notice

www.text JSON as string array.

Discussion in 'Scripting' started by bpritchard, May 31, 2014.

  1. bpritchard


    Jan 29, 2009
    Afternoon all,

    I'm having a problem reading in a JSON string from www. I'm using it in other places and it works fine, but this one particular function is returning what looks like an array of strings vs a single collection i can pass in as a dictionary. Here's a sample of the input string i'm getting...

    Code (csharp):
    2. [{"id":"7","x":"28.32","y":"0","z":"-1.28","angle":"0.104","level":"1"},{"id":"8","x":"25.3","y":"0","z":"-1.59","angle":"0.104","level":"1"}]
    Each one is a unique set of parameters but all the parameter values are the same across them all (aka angle is always angle). I have a number of those coming in in 1 string.

    So my question is.. is there an easy way to convert the above to a list that i can then use to make a dictionary per list item? I haven't been able to figure out an easy way to go from string to stringArray or anything along those lines.

    Any insight would be awesome. If i can get that into a usable string collection then i can get each one into the dictionary properly.