JsonUtility : When I'm saving/loading to/from .Json, do I need a C# object for every child object of my .json file?

Hey guys! I’m working on creating a flexible Unit Editor scene within unity to allow me to more easily mass-produce different kinds of units for my game. I want to store the data of each unit as multi-layered/nested JSON objects. For instance, every Unitdata JSON object has within it ParameterData, AnimationData, and CodexData which then each have child parameters, etc.

Now, I’ve followed a couple of tutorials but none of them are dealing with a situation quite as complex as mine.

Each of them are simply pulling from single JSON objects that have a bunch of properties, and in their scripts/code they have a matching Class that represents the entire JSON object and all of its properties.
So my question is this: do I really have to make a class(object) for every single sub-object within my JSON?

Like do I need to make a ParameterData class and a CodexData class, etc? and then my UnitData class simply has properties made of all of its child classes?

And then… when I do JsonUtility.FromJson/ToJson, if I pass in the most parent object, will it be able to automatically get all of the data within all of those child objects? Like will I need to loop/enumerate through all the objects somehow, or anything like that?

Here is my .json file I’m working with, if it helps:

When you use Unity’s JsonUtility, yes, you have to create a class for every object in your json structure since the JsonUtility is an object mapper / serializer. However instead of Unity’s JsonUtility you could also use my SimpleJSON framework. It just parses the json text into a custom object tree and you can access any element node by string / index. For example

// parse your json text
var node = JSON.Parse(yourJsonText);

string unitName = node["unitData"]["parameterData"]["unitName"].Value;

// get a sub node in a local variable for later use
JSONNode storyData = node["unitData"]["storyData"];

int age = storyData["age"].AsInt;
float width = storyData["age"].AsFloat;

Note that I created an extension file which adds extra support for some of Unity’s primitive types. Specifically Vector2/3/4, Quaternion, Rect, … which makes it easier to read and write such values. This extension file just need to sit next to the SimpleJSON.cs file.