I have a string like:
{InstanceStatuses: [{AvailabilityZone: us-east-2b,Events: [],InstanceId: i-79e234fd, InstanceState: {Code: 16,Name: running},InstanceStatus: {Details: [{Name: reachability,Status: initializing}],Status: initializing},SystemStatus: {Details: [{Name: reachability,Status: initializing}],Status: initializing}}],}
how to convert it to an Object(like hashmap) in java? Thank you!
troy
2,5453 gold badges28 silver badges33 bronze badges
1 Answer 1
Where do you get those strings? Because if it is from amazon (I see an amazon tag in your question) it is very likely that an (official) parser already exists for java. If not, I think your only chance is to write a parser by your own (could get quite difficult). I think your best choice for the start is to look where you get the string and then search for a java parser.
Sign up to request clarification or add additional context in comments.
2 Comments
paulsm4
@Catchy - please upvote and "accept" this answer - it's basically the ONLY answer: 1) If you're getting this string from some vendor (e.g. Amazon), perhaps that vendor has a library. 2) Otherwise, you'll have to parse it yourself. Looking at the format, I think writing the "parsing code" in Java might actually be pretty easy ;)
WinterKi
I am not good at string parsing. Can you write a demo? Thank you
lang-java