Skip to content

JsonData corrupts empty objects & arrays #128

@discordgr

Description

@discordgr

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions