LitJSON/litjson

JsonData corrupts empty objects & arrays

discordgr opened this issue · 0 comments

I'm not sure how to properly explain the issue i have, so i'm gonna type an example.
I have a generic json response, that i break it down to a class using JsonMapper.ToObject<Response>(response)

    public class Response{
        public JsonData data {get; set;},
        public int status {get; set;}
    }
    

After this class, data can break down to different types of objects depending on the response.

And i want to be able to map it again with:
JsonMapper.ToObject<MyClass>(myResponse.data.ToJson())

The issue here is that if within JsonData there was an empty object or an empty array, the property is corrupted and instead being like this: "array" : [], it is like this: "array" : and i get a KeyNotFoundException.

Is there any workaround for this? Am i doing something wrong?