3

^--- For rebuttal of assertion that question is a mere duplicate, see Note at bottom.

spoiler: see bottom of question for final code based on carldevelopsforcoffee's accepted answer that works.

Original question:

I'm attempting to parse a complex JSON file (see below) using C# in Unity (2018.1, VS2015 if it matters) using UnityEngine.JsonUtility.FromJson(). The parser code is listed below.

The top-level variables (sweepIndex, totalRadials, etc) all parse fine into the Sweep object, but the 'radials' array appears to be getting skipped (the List of Radial objects in Sweep ends up null).

If it's not obvious from the JSON, it has the following structure:

  • A top-level "Sweep" object with 13 simple values and an array of Radial objects.

  • Each Radial object in the List has 4 simple values, and an array of doubles

Formatted JSON to illustrate structure:

(edited & truncated for clarity... full JSON is String in class below)

{"sweepIndex":0,
"totalRadials":720,
"beamWidth":0.949999988079071,
"startingUnixtime":1536864392000,
"endingUnixtime":1536863574000,
"totalGatesPerRay":1832,
"gateDepthMeters":250.0,
"distanceToFirstGateMeters":2125.0,
"meanElevationDeg":0.5275726318359375,
"originLatitude":33.989444444444445,
"originLongitude":-78.42888888888889,
"originAltitude":20.0,
"deviantOriginCount":0,
"radials": [
    {"radialNumber":0,"azimuthDeg":263.21319580078125,"elevationDeg":0.53009033203125,"duration":66521592,
        "gateIntensity":[-5.5,-1.0,1.0,3.0,13.5,-15.0,-13.0,-11.5,-10.5,-7.5]},
    {"radialNumber":1,"azimuthDeg":263.7432861328125,"elevationDeg":0.5328369140625,"duration":66521616,
        "gateIntensity":[-9.5,-1.0,-4.5,-2.5,5.0,-4.0,9.0,-8.5,-1.5,-9.0]}
]}

I'm the one generating the JSON file (using Netcdf-Java to inhale the raw level-2 radar data and spit it out as JSON for the Unity app to consume), so I could probably change the JSON if it made my life enormously easier... but I'd really prefer to not substantially change the overall structure (Sweep Object with array of Radial Objects with array of doubles).

The class:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using UnityEngine;


namespace Assets.Scripts {
    public class RadarData {
        private String site;
        private Sweep sweep;

        public RadarData(String site) {
            this.site = site;
            String src = @"{""sweepIndex"":0,""totalRadials"":720,""beamWidth"":0.949999988079071,""startingUnixtime"":1536863321000,""endingUnixtime"":1536863574000,""totalGatesPerRay"":1832,""gateDepthMeters"":250.0,""distanceToFirstGateMeters"":2125.0,""meanElevationDeg"":0.5275726318359375,""originLatitude"":33.989444444444445,""originLongitude"":-78.42888888888889,""originAltitude"":20.0,""deviantOriginCount"":0,""radials"":[{""radialNumber"":0,""azimuthDeg"":263.21319580078125,""elevationDeg"":0.53009033203125,""duration"":66521592,""gateIntensity"":[-5.5,-1.0,1.0,3.0,13.5,-15.0,-13.0,-11.5,-10.5,-7.5,-5.0,-3.5,-2.0,-19.5,-13.5,-11.0,-9.0,-6.0,-6.0,-6.0,-6.5,-7.0,-3.5,-4.5,-5.5,-6.5,-13.0,-11.0,-9.5,-11.5,-11.5,-11.0,-10.5,-7.0,-5.0,-3.5,-10.5,-9.5,-9.0,-8.5,-1.0,-1.5,-2.5,-4.0,-6.0,-11.5,-5.5,6.5,-0.5,-10.0,-14.5,-2.5,9.5,5.0,11.0,-1.0,-4.0,-4.0,-4.5,-5.0,-6.0,-7.0,-1.0,6.0,-9.0,-5.5,-9.0,-3.5,3.5,-0.5,14.0,-7.0,14.5,7.0,13.5,0.0,3.0,-6.0,-9.0,-1.5,-0.5,-2.5,2.5,2.0,1.0,0.0,-1.0,-0.5,-3.5,-2.5,5.5,1.5,2.0,-4.5,-7.5,-4.0,-2.0,-2.0,-2.0,-2.0,-2.0,-0.5,0.0,3.5,-8.0,-3.5,-2.5,4.5,-5.0,-2.5,-1.0,-2.0,-2.5,4.5,-3.5,1.5,-6.5,-4.5,-6.5,1.0,-2.5,-2.5,-1.5,-2.0,-0.5,-4.0,1.0,-2.5,-2.0,-5.0,1.5,3.5,2.0,-6.5,2.5,5.0,1.0,4.0,-2.5,-4.5,2.5,-5.5,2.0,-3.5,0.5,0.0,-0.5,3.0,6.5,-7.0,-2.0,0.5,-1.0,3.0,2.0,-1.0,3.0,1.0,1.5,-1.0,-1.0,5.0,-1.0,2.5,-5.0,-2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,-1.0,-1.0,-1.0,-1.0]}]}";
            this.sweep = JsonUtility.FromJson<Sweep>(src);
        }

        public String toString() {
            StringBuilder s = new StringBuilder();

            s.AppendFormat("{0} at ({1},{2}), elevation={3}m\n", site, sweep.originLatitude, sweep.originLongitude, sweep.originAltitude);
            foreach (Radial r in sweep.radials) {
                s.AppendFormat("\tRadial #{0} -- az={1}, el={2}\n", r.radialNumber, r.azimuthDeg, r.elevationDeg);
            }

            return s.ToString();
        }

    }

    public class Sweep {
        public int sweepIndex;
        public int totalRadials;
        public float beamWidth;
        public long startingUnixtime;
        public long endingUnixtime;
        public int totalGatesPerRay;
        public float gateDepthMeters;
        public float meanElevationDeg;
        public double originLatitude;
        public double originLongitude;
        public float originAltitude;
        public int deviantOriginCount;
        public List<Radial> radials;
    }

    public class Radial {
        public int radialNumber;
        public float azimuthDeg;
        public float elevationDeg;
        public long duration;
        public List<double> gateIntensity;

    }

}

Note:

The question for which the user "Programmer" has stated that this is an alleged duplicate has an answer that doesn't actually solve my stated problem -- complex JSON in Unity. It establishes that Unity's built in JsonUtility class is inadequate for parsing complex JSON, while offering no real alternative.

There are questions on SO about using third-party Json libraries with C#... but using third-party libraries with C# in a Unity project is considerably harder and more specific of a task if they aren't already available as a .unitypackage, especially if it needs to be capable of ultimately working on platforms besides Windows (eg, Android, Magic Leap, Oculus, etc).

That's why the accepted answer to this question is valuable & adds concrete value to SO as a resource... it identifies a solution that addresses the questions's three specific issues -- complex Json, C#, and getting it to work in Unity in a platform-agnostic manner.

Final working code (based on accepted answer)

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using UnityEngine;

using JsonFx.Json;
using UnityEditor;


namespace Assets.Scripts {
    public class RadarData {
        private String site;
        private Sweep sweep;

        public RadarData(String site) {
            this.site = site;
            TextAsset src = AssetDatabase.LoadAssetAtPath("Assets/RadarData/" + site + ".json", typeof(TextAsset)) as TextAsset;

            var reader = new JsonReader();
            dynamic output = reader.Read(src.ToString());

            sweep = new Sweep();
            sweep.sweepIndex = output["sweepIndex"];
            sweep.beamWidth = (float) output["beamWidth"];
            sweep.startingUnixtime = output["startingUnixtime"];
            sweep.endingUnixtime = output["endingUnixtime"];
            sweep.totalGatesPerRay = output["totalGatesPerRay"];
            sweep.gateDepthMeters = (float)(output["gateDepthMeters"]);
            sweep.meanElevationDeg = (float)(output["meanElevationDeg"]);
            sweep.originLatitude = (float)(output["originLatitude"]);
            sweep.originLongitude = (float)(output["originLongitude"]);
            sweep.originAltitude = (float)(output["originAltitude"]);
            sweep.deviantOriginCount = output["deviantOriginCount"];

            Dictionary<String,object>[] radials = output["radials"];
            sweep.setRadials(radials);
        }

        public Sweep getSweep(int sweepNumber) {
            return sweep;
        }


        public String toString() {
            return sweep.ToString();
        }

    }

    public class Sweep {
        public int sweepIndex;
        public int totalRadials;
        public float beamWidth;
        public long startingUnixtime;
        public long endingUnixtime;
        public int totalGatesPerRay;
        public float gateDepthMeters;
        public float meanElevationDeg;
        public float originLatitude;
        public float originLongitude;
        public float originAltitude;
        public int deviantOriginCount;
        public List<Radial> radials;

        public void setRadials(Dictionary<String,object>[] src) {

            radials = new List<Radial>();
            foreach (Dictionary<String,object> rad in src) {
                radials.Add(new Radial(rad));
            }
        }

        override public String ToString() {
            StringBuilder s = new StringBuilder();

            s.AppendFormat("Sweep[index={0}... {1} Radials]", sweepIndex, radials.Count());

            return s.ToString();
        }
    }

    public class Radial {
        public int radialNumber;
        public double azimuthDeg;
        public double elevationDeg;
        public long duration;
        public double[] gateIntensity;

        public Radial(Dictionary<String,object> d) {
            radialNumber = (int)(d["radialNumber"]);
            azimuthDeg = (double)(d["azimuthDeg"]);
            elevationDeg = (double)(d["elevationDeg"]);
            duration = long.Parse(d["duration"].ToString());
            gateIntensity = (double[])(d["gateIntensity"]);
        }
    }
}
Bitbang3r
  • 6,826
  • 5
  • 27
  • 40
  • 1
    Is there a reason you can't use `Newtonsoft.Json`? – Dai Sep 14 '18 at 00:00
  • @Dai AFAIK Newtonsoft and Unity didn't used to play well together – DavidG Sep 14 '18 at 00:01
  • I looked at Newtonsoft.Json earlier, but couldn't figure out what I had to do to make it work with Unity (and ensure it would work on non-Windows platforms, like Android & Magic Leap). – Bitbang3r Sep 14 '18 at 00:12
  • I don't know that we use this specific package, but we do use it on Android, iOS, Windows, and Mac. WebGL also works with minor modifications. https://assetstore.unity.com/packages/tools/input-management/json-net-for-unity-11347 – Retired Ninja Sep 14 '18 at 00:36
  • @Bitbang3r I use Newtonsoft.Json for serializing and deserializing in Unity without any issue :O – Erik Šťastný Sep 14 '18 at 06:07
  • You just need to add `[Serializable]` to the top of the classes you want to serialize/deserialize as [Everts](https://stackoverflow.com/a/52325813/3785314) mentioned. Also, if you already have the json, it's better to use a tool like [[this](http://json2csharp.com/) to generate the object. See duplicate for more info about getting null in the variables. – Programmer Sep 14 '18 at 09:58
  • I have used Newton soft in the past by integrated dll libs somewhere. Can confirm the new JSONUtility just doesn't work well at all- sigh. – Jamie Nicholl-Shelley Jan 16 '21 at 17:09

3 Answers3

8

Copy paste your json and http://json2csharp.com/

You will get this:

public class Radial
{
    public int radialNumber { get; set; }
    public double azimuthDeg { get; set; }
    public double elevationDeg { get; set; }
    public int duration { get; set; }
    public List<double> gateIntensity { get; set; }
}

public class RootObject
{
    public int sweepIndex { get; set; }
    public int totalRadials { get; set; }
    public double beamWidth { get; set; }
    public long startingUnixtime { get; set; }
    public long endingUnixtime { get; set; }
    public int totalGatesPerRay { get; set; }
    public double gateDepthMeters { get; set; }
    public double distanceToFirstGateMeters { get; set; }
    public double meanElevationDeg { get; set; }
    public double originLatitude { get; set; }
    public double originLongitude { get; set; }
    public double originAltitude { get; set; }
    public int deviantOriginCount { get; set; }
    public List<Radial> radials { get; set; }
}

Then you can use the JsonUtility but you first need to modify some content. Add Serializable attribute to each class and remove the property extension to make those basic variables.

[Serializable]
public class Radial
{
    public int radialNumber;
    public double azimuthDeg;
    public double elevationDeg;
    public int duration;
    public List<double> gateIntensity;
}
[Serializable]
public class RootObject
{
    public int sweepIndex;
   // same with all following items
}

RootObject is the top class of your json, it has no name in the json so default is generated. You can change RootObject to anything you want like JsonResponse. This is now ready to use like this:

void Start()
{
     string json = GetJsonFile(); // From download or text file
     RootObject ro = JsonUtility.FromJson<RootObject>(json);
     print( ro.radials[0].radialNumber); 
}
Everts
  • 10,408
  • 2
  • 34
  • 45
  • This is a nice clear answer, except there's one tiny problem... it didn't actually work when I tried it. The `List radials` object still ended up being null at runtime. I'm not saying your solution is wrong... just that it didn't work in my specific build environment when I tried it (which could be due to anything from a recent bug/bugfix in Unity, .net differences, VS config, Unity config, or other issues). If you actually witnessed it working in Unity on your computer, I'd be interested in trying to figure out how our configurations diverge to identify the root problem. – Bitbang3r Sep 14 '18 at 18:51
  • 1
    Did you remove the get;set on all references? – Everts Sep 15 '18 at 11:58
  • Yes, I removed them from all references. – Bitbang3r Sep 18 '18 at 01:33
  • Thanks, that solved exactly my issue! – stacklikemind Mar 14 '19 at 20:41
  • Bless your heart. – Tyler Thomas May 20 '21 at 23:12
  • I had complex json where the root structure had an object, which had a list, and each item in that list has a list, and in testing I'm now able to access everything. This was immensely helpful. – Nik Hammer-Ellis Oct 28 '21 at 03:30
1

I use JsonFx for my data classes in Unity.

Example Class:

using JsonFx.Json;

[Serializable]
[JsonName("MyData")]
public class MyData
{
    public int id;
    public string name;
    public int[] stuff;
}

Sample json:

{
    "__Type": "MyData, Assembly-CSharp",
    "id": 1,
    "name": "new_data",
    "stuff" :
       [
         0,
         1,
         2
        ]
 }

Creating your data object from json :

// Json to MyData object: 
// Assume I downloaded a json file
string jsonData = System.Text.Encoding.UTF8.GetString (www.bytes);
jsonData = jsonData.Trim ();
MyData data = MyData.Deserialize(jsonData);

Creating your json file from a data object

// MyData object to Json
// Use MyData data object
string file = "mydata.json";
JsonWriterSettings settings = new JsonWriterSettings ();
settings.PrettyPrint = true;
settings.TypeHintName = "__Type";

JsonWriter writer = new JsonWriter (file, settings);
writer.Write (data);
writer.TextWriter.Flush ();
writer.TextWriter.Close ();
  • Hmmm... a couple of questions... I added Unity-JsonFX-2.0.unitypackage, and tried to use" var reader = new JsonReader(); " followed by " dynamic output = reader.Read(src); ", but when I subsequently attempted to read the values as " output["variableName"] " (ex: output["originLatitude"] ), I got errors like error CS1980: Dynamic keyword requires 'System.Runtime.CompilerServices.DynamicAttribute' to be defined. Are you missing System.Core.dll assembly reference? and error CS1969: Dynamic operation cannot be compiled without 'Microsoft.CSharp.dll' assembly reference. (continued) – Bitbang3r Sep 14 '18 at 03:58
  • I suspect the errors are due to using ".NET 3.5-Equivalent" instead of ".NET 4.x-Equivalent"... before I blindly change it, though, are there any real consequences to switching to 4.x (esp. since it'll ultimately be used on non-Windows platforms)? – Bitbang3r Sep 14 '18 at 04:02
  • Also... I tried using `Sweep s = Sweep.Deserialize(src);` (following your example with `MyData data = MyData.Deserialize(jsonData);`, but VS didn't recognize that as valid. Is that another 3.5-vs-4.x issue? Finally... I noticed the first line of your example JSON is `"__Type": "MyData, Assembly-CSharp",`... is that something I need to add? Thanks! – Bitbang3r Sep 14 '18 at 04:06
  • OK, accepted your answer & posted the revised version of my class that incorporates it. It wasn't quite as pretty as I would have liked, but it at least solved the core roadblock & enabled me to move forward. Thanks! – Bitbang3r Sep 14 '18 at 19:04
  • When deserializing, `MyData.Deserialize(jsonData)`, the `"__Type": "MyData, Assembly-CSharp"` is important. When using json that was created from another source (like from a web instance), you could use `JsonReader.Deserialize (jsonData)` – carldevelopsforcoffee Sep 17 '18 at 00:03
0

There is an online service that can auto-convert from Json to Poco, for instance

In VisualStudio, there is also a menu that does so:

enter image description here

David
  • 15,894
  • 22
  • 55
  • 66