I'm trying to convert a JSON string (returned on a HTTP Response by a web service) to a HashMap. In Python, I could've simply used json.loads(string_response)
and it would've given me a nice dictionary. I'm trying to find a similar thing in Java.
My snippet is-
String result = "{\"packetsReceived_Audio\":\"\",\"packetsReceived_Screen\":\"\",\"packetsReceived_Video\":\"\",\"packetsSent_Audio\":\"\",\"packetsSent_Screen\":\"\",\"packetsSent_Video\":\"\",\"sequenceNumber\":\"0\"}";
Map map = Splitter.on(",").withKeyValueSeparator(":").split(result);
As one of the comments below point out that it should already return a hash map, it really isn't. Its returning me a collection with each item containing sub items - "key" and "value". See attached image for clarity. What I'm expecting is a HashMap.
I know I can add another step to create a usual Map but I wanted to check if there's something available in the framework already.
Thanks!