JSON Parse Issue

Can someone tell me what the class should look like to parse to JSON like this:

{
“All”: {
“All”: [
“All”,
“Lincoln Memorial University”,
“Louisiana State University”,
“Mississippi State University”
],
“Suture Pattern”: [
“All”,
“Louisiana State University”,
“Mississippi State University”
],
“Urinary”: [
“All”,
“Lincoln Memorial University”,
“Louisiana State University”
],
“Incision Tech”: [
“All”,
“Louisiana State University”,
“Mississippi State University”
],
“Surgical Prep”: [
“All”,
“Lincoln Memorial University”,
“Louisiana State University”,
“Mississippi State University”
],
“Abdominal”: [
“Louisiana State University”
],
“Dermatology”: [
“Louisiana State University”
],
“Clinical Pathology”: [
“Lincoln Memorial University”
],
“Anesthesia”: [
“Lincoln Memorial University”
],
“Reproductive”: [
“All”,
“Lincoln Memorial University”,
“Louisiana State University”,
“Mississippi State University”
],
“Upper Respiratory”: [
“Louisiana State University”
],
“Gastrointestinal”: [
“Louisiana State University”
],
“Closure Tech”: [
“Mississippi State University”
],
“Orthopedic”: [
“Louisiana State University”
],
“Anatomy”: [
“Louisiana State University”
],
“Theriogenology”: [
“Lincoln Memorial University”
]
},
“Skill”: {
“All”: [
“All”,
“Lincoln Memorial University”,
“Louisiana State University”,
“Mississippi State University”
],
“Anesthesia”: [
“Lincoln Memorial University”
],
“Clinical Pathology”: [
“Lincoln Memorial University”
],
“Closure Tech”: [
“Mississippi State University”
],
“Incision Tech”: [
“All”,
“Louisiana State University”,
“Mississippi State University”
],
“Surgical Prep”: [
“All”,
“Lincoln Memorial University”,
“Louisiana State University”,
“Mississippi State University”
],
“Suture Pattern”: [
“All”,
“Louisiana State University”,
“Mississippi State University”
],
“Theriogenology”: [
“Lincoln Memorial University”
],
“Urinary”: [
“Lincoln Memorial University”
]
},
“Canine”: {
“Abdominal”: [
“Louisiana State University”
],
“All”: [
“All”,
“Lincoln Memorial University”,
“Louisiana State University”,
“Mississippi State University”
],
“Anatomy”: [
“Louisiana State University”
],
“Dermatology”: [
“Louisiana State University”
],
“Gastrointestinal”: [
“Louisiana State University”
],
“Incision Tech”: [
“Louisiana State University”
],
“Reproductive”: [
“All”,
“Lincoln Memorial University”,
“Louisiana State University”,
“Mississippi State University”
],
“Theriogenology”: [
“Lincoln Memorial University”
],
“Urinary”: [
“Louisiana State University”
]
},
“Equine”: {
“All”: [
“All”,
“Lincoln Memorial University”,
“Louisiana State University”
],
“Anesthesia”: [
“Lincoln Memorial University”
],
“Orthopedic”: [
“Louisiana State University”
],
“Upper Respiratory”: [
“Louisiana State University”
]
},
“Feline”: {
“Reproductive”: [
“All”,
“Lincoln Memorial University”,
“Louisiana State University”,
“Mississippi State University”
]
}
}

Thank you

Hi,
Did you even do a superficial search about this, like Unity JSON parser? And please use code blocks for code. And it wouldn’t probably have needed much more effort to run some beautify/format in some editor.

There are many discussions here on Unity forums how to parse JSON data using Unity’s own tools, search for them first to get an overall idea. But It’s probably best idea to look for some 3rd party JSON library as Unity’s JsonUtility isn’t very flexible.

Yes, I have done several searches and am parsing other JSON. It is this specific format I am having trouble with. But I will look for 3rd party libraries. I am using Unity’s.

I am still not sure how to use the Unity JSON Utility to put this JSON into a class but for now, I will work around it by using this 3rd party parser https://assetstore.unity.com/packages/tools/input-management/json-object-710

I usually use http://json2csharp.com/ if I have any questions on class structure. But I also generally use json.net instead of Unity’s json.

1 Like

For the above data that OP posted, it looks like a Dictionary, which means you MUST use something besides Unity’s JSON. Unity’s JSON is more like a “tiny JSON” intended for performant deserialization of pre-structured data only, not free-form JSON.

There is a JSON.NET available on the asset store for free, works awesome.