Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JsonData corrupts empty objects & arrays #128

Open
discordgr opened this issue Mar 8, 2022 · 0 comments
Open

JsonData corrupts empty objects & arrays #128

discordgr opened this issue Mar 8, 2022 · 0 comments

Comments

@discordgr
Copy link

discordgr commented Mar 8, 2022

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?

@discordgr discordgr changed the title JsonData corrupts empty objects & arrays when used inside JsonMapper.ToObject JsonData corrupts empty objects & arrays Mar 8, 2022
@discordgr discordgr changed the title JsonData corrupts empty objects & arrays JsonData corrupts empty objects & arrays Mar 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant