1

I am attempting to read in the following json using the jackson java library:

"WeirdData": {
  "07f072ea-80c9-4fac-8235-2e1e6576ce2e": "crapapple"
},

How should the model look like to be able to be able to read above json into a class, can this even be done?

class SponsorEntityIdsData {
  @JsonProperty("GUID")
  var id: String? = null
  var name: String? = null
}
5
  • This is not a valid JSON, is your example part of larger JSON object? Commented Jul 20, 2018 at 23:01
  • This is data I am getting from an api endpoint. I suspected that this data would not be valid, I'll try and convince the api owner to fix this. yes, this is part of major blob of data. Commented Jul 20, 2018 at 23:05
  • I don't believe that Jackson can handle invalid JSON input Commented Jul 20, 2018 at 23:06
  • What do you mean by this is part of major blob of data? Did you cut the example off of the complete JSON content? If so, we'd need a minimal, yet complete example of said blob/JSON. Commented Jul 20, 2018 at 23:12
  • Yes, since it didn't appear to be relevant, the json looked "normal" and I was trying to simplify. Commented Jul 20, 2018 at 23:13

1 Answer 1

1

Try to use HashMap Collection in your java pojo class. You will get id (key) by using WeirdData.keySet() and by using key you will get name.

class WeirdData {
 HashMap<String,String> WeirdData;
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.