r/Unity3D•
Copun

Is it possible to check if a field was missing using JsonUtility.FromJson()?

Question

Hi guys, was wondering if there is a way to check if a field was missing during deserialization of a json file using Unity's built in json utility?

Posted Apr 12, 2017, 12:25 AM UTC

13
DolphinsAreOkProfessional•

No, you'd best get an opensource JSON library and adjust it to your needs.

1
apieceoffruit•

I've not used unitys (I use json.net) but have you tried using a nullable type?

       [SerializeField] bool? MyThing;

and checking if it is null?

1
Kretin1•

Yes this.

If it's null or default value, it's missing.

1