I'm using a C# app where data classes I use look like this :
class Node {
public string name;
public int id;
public Node parent;
public Node[] children;
public Data data;
}
class Community {
public Node[] nodes;
}
class Data {
public string info;
public int value;
}
I declare in javascript these objects :
var Node = {
name: '',
id: '',,
parent: '',
children: '',
data: ''
}
var Community = {
nodes: ''
}
var Data = {
info: '',
value: ''
}
Those are obviously simplified versions of the real deal, but I'd like to know how I can tell the javascript JSON deserializer to build the fields properly, using the objects I declared.
I need to make some sort of CMS for this so it's important that all the keys are available, even if they hold no value, which is why I want to declare objects and have the deserialiser use them.
For instance, I want to be able to access Community.nodes[3].data.info
even if it wasn't set in the JSON file.