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

Parse nested attributes without nested objects #190

Open
mdelgado opened this issue Dec 6, 2016 · 0 comments
Open

Parse nested attributes without nested objects #190

mdelgado opened this issue Dec 6, 2016 · 0 comments

Comments

@mdelgado
Copy link

mdelgado commented Dec 6, 2016

Hi,
I've run into this situation in various projects and I was wondering if there's a way to retrieve nested properties without using nested objects.

The problem starts when I'm provided with a web api which gives a non-optimal response structure and neither is there a possibility to optimize it, for example something like the following JSON:

{
    result: {
        errors: [
            {
                message: "Some error"
            }
        ]
    }
}

Yeah, as awful and ilogical as it seems, I've had to deal with those kind of responses which make me create unnecesary nested objects just to extract that message.

What I'd like to be able to do is something like this:

@JsonObject
public class Result {
    @JsonField(name = "result/errors[0]/message")
    protected String error;
}

Please consider adding this feature, it'd be awesome to be able to write clean code like that.

Thanks!

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