Convert JSON to MapSimplest way to convert a string representing JSON array into Java array List of key value pairsHow to take String JSON values into HashMapConvert a JSON String to a HashMapCreating BSON object from JSON stringJSONObject - How to get a value ?Better Map ConstructorReading JSON from Url javaUpdate columns if input values are not null otherwise ignore and keep the existing values of column in databaseHow to store object represented as Json string into Couchbase Lite?Go JSON into MapHow do I efficiently iterate over each entry in a Java Map?Sort a Map<Key, Value> by valuesHow to round a number to n decimal places in JavaCan comments be used in JSON?How do I read / convert an InputStream into a String in Java?How can I pretty-print JSON in a shell script?What is the correct JSON content type?How can I deserialize JSON to a simple Dictionary<string,string> in ASP.NET?Why does Google prepend while(1); to their JSON responses?Parse JSON in JavaScript?
How to know if a folder is a symbolic link?
Looking for a soft substance that doesn't dissolve underwater
Is there a way to make it so the cursor is included when I prtscr key?
If a person had control of every single cell of their body, would they be able to transform into another creature?
Why do most published works in medical imaging try to reduce false positives?
Why do Ryanair allow me to book connecting itineraries through a third party, but not through their own website?
Does Nitrogen inside commercial airliner wheels prevent blowouts on touchdown?
Are these reasonable traits for someone with autism?
How to make a villain fall in love?
Would jet fuel for an F-16 or F-35 be producible during WW2?
Is there an efficient way to replace text matching the entire content of one file with the entire content of another file?
Using credit/debit card details vs swiping a card in a payment (credit card) terminal
Should I disclose a colleague's illness (that I should not know) when others badmouth him
Is it possible to play as a necromancer skeleton?
Which is the common name of Mind Flayers?
Why do compressed liquids heat up when allowed to expand unlike gases?
Defining the standard model of PA so that a space alien could understand
how to grep in the output of ls -a
Why did David Cameron offer a referendum on the European Union?
In general, would I need to season a meat when making a sauce?
Passing arguments from TeX to a Lua function
What are these arcade games in Ghostbusters 1984?
At what point in European history could a government build a printing press given a basic description?
I think I may have violated academic integrity last year - what should I do?
Convert JSON to Map
Simplest way to convert a string representing JSON array into Java array List of key value pairsHow to take String JSON values into HashMapConvert a JSON String to a HashMapCreating BSON object from JSON stringJSONObject - How to get a value ?Better Map ConstructorReading JSON from Url javaUpdate columns if input values are not null otherwise ignore and keep the existing values of column in databaseHow to store object represented as Json string into Couchbase Lite?Go JSON into MapHow do I efficiently iterate over each entry in a Java Map?Sort a Map<Key, Value> by valuesHow to round a number to n decimal places in JavaCan comments be used in JSON?How do I read / convert an InputStream into a String in Java?How can I pretty-print JSON in a shell script?What is the correct JSON content type?How can I deserialize JSON to a simple Dictionary<string,string> in ASP.NET?Why does Google prepend while(1); to their JSON responses?Parse JSON in JavaScript?
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;
What is the best way to convert a JSON code as this:
"data" :
"field1" : "value1",
"field2" : "value2"
in a Java Map in which one the keys are (field1, field2) and the values for those fields are (value1, value2).
Any ideas? Should I use Json-lib for that? Or better if I write my own parser?
java json parsing collections
add a comment |
What is the best way to convert a JSON code as this:
"data" :
"field1" : "value1",
"field2" : "value2"
in a Java Map in which one the keys are (field1, field2) and the values for those fields are (value1, value2).
Any ideas? Should I use Json-lib for that? Or better if I write my own parser?
java json parsing collections
I have written code for this without using any library. stackoverflow.com/questions/21720759/jsonobject-to-map/…
– Vikas Gupta
Oct 31 '14 at 9:43
add a comment |
What is the best way to convert a JSON code as this:
"data" :
"field1" : "value1",
"field2" : "value2"
in a Java Map in which one the keys are (field1, field2) and the values for those fields are (value1, value2).
Any ideas? Should I use Json-lib for that? Or better if I write my own parser?
java json parsing collections
What is the best way to convert a JSON code as this:
"data" :
"field1" : "value1",
"field2" : "value2"
in a Java Map in which one the keys are (field1, field2) and the values for those fields are (value1, value2).
Any ideas? Should I use Json-lib for that? Or better if I write my own parser?
java json parsing collections
java json parsing collections
edited Nov 27 '17 at 22:18
Donald Duck
4,142134263
4,142134263
asked Jan 14 '09 at 16:00
David SantamariaDavid Santamaria
5,23062942
5,23062942
I have written code for this without using any library. stackoverflow.com/questions/21720759/jsonobject-to-map/…
– Vikas Gupta
Oct 31 '14 at 9:43
add a comment |
I have written code for this without using any library. stackoverflow.com/questions/21720759/jsonobject-to-map/…
– Vikas Gupta
Oct 31 '14 at 9:43
I have written code for this without using any library. stackoverflow.com/questions/21720759/jsonobject-to-map/…
– Vikas Gupta
Oct 31 '14 at 9:43
I have written code for this without using any library. stackoverflow.com/questions/21720759/jsonobject-to-map/…
– Vikas Gupta
Oct 31 '14 at 9:43
add a comment |
14 Answers
14
active
oldest
votes
I hope you were joking about writing your own parser. :-)
For such a simple mapping, most tools from http://json.org (section java) would work.
For one of them (Jackson, http://wiki.fasterxml.com/JacksonInFiveMinutes), you'd do:
HashMap<String,Object> result =
new ObjectMapper().readValue(JSON_SOURCE, HashMap.class);
(where JSON_SOURCE is a File, input stream, reader, or json content String)
32
Moreover, if you want a typed Map (exploiting java generics), you can do : Map<String, MyPojo> typedMap = mapper.readValue(jsonStream, new TypeReference<Map<String, MyPojo>>() );
– obe6
Dec 29 '14 at 20:46
3
If you work with Maven project, you will need <dependency> <groupId>com.fasterxml.jackson.core</groupId> <artifactId>jackson-databind</artifactId> <version>2.4.4</version> </dependency>
– LoBo
Nov 2 '15 at 9:49
1
And looks like Jackson has moved since 09 so: Jackson data-bind
– jacob.mccrumb
Sep 21 '16 at 18:42
@obe6 I guess the OP is not joking. Can you find a single "JSON" anywhere in your code snippet other than that arbitrary variable name? I'm struggling too because of the names in Jackson API.
– Aetherus
Nov 22 '18 at 9:39
FWTW, while @obe6's answer is technically correct, you can use shorter form too:Map<String,Object> result = mapper.readValue(source, Map.class)
.
– StaxMan
Nov 28 '18 at 6:40
add a comment |
I like google gson library.
When you don't know structure of json. You can use
JsonElement root = new JsonParser().parse(jsonString);
and then you can work with json. e.g. how to get "value1" from your gson:
String value1 = root.getAsJsonObject().get("data").getAsJsonObject().get("field1").getAsString();
14
This can throw NullPointerExceptions 5 different ways if you get unexpected data.
– dfraser
Aug 27 '15 at 14:31
i hate the google gson library, it's rubbish
– bharal
Jan 9 at 18:22
add a comment |
Using the GSON library:
import com.google.gson.Gson;
import com.google.common.reflect.TypeToken;
import java.lang.reclect.Type;
Use the following code:
Type mapType = new TypeToken<Map<String, Map>>().getType();
Map<String, String[]> son = new Gson().fromJson(easyString, mapType);
5
java at its best:TypeToken<Map<String, Map>>
:-)
– froderik
Oct 26 '14 at 8:10
With new TypeToken<Map<String, Object>> it will work also when there are arrays inside.
– 9ilsdx 9rvj 0lo
Jan 10 '18 at 13:19
add a comment |
Use JSON lib E.g. http://www.json.org/java/
// Assume you have a Map<String, String> in JSONObject jdata
@SuppressWarnings("unchecked")
Iterator<String> nameItr = jdata.keys();
Map<String, String> outMap = new HashMap<String, String>();
while(nameItr.hasNext())
String name = nameItr.next();
outMap.put(name, jdata.getString(name));
add a comment |
My post could be helpful for others, so imagine you have a map with a specific object in values, something like that:
"shopping_list":
"996386":
"id":996386,
"label":"My 1st shopping list",
"current":true,
"nb_reference":6
,
"888540":
"id":888540,
"label":"My 2nd shopping list",
"current":false,
"nb_reference":2
To parse this JSON file with GSON library, it's easy :
if your project is mavenized
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.3.1</version>
</dependency>
Then use this snippet :
import com.google.gson.Gson;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
//Read the JSON file
JsonElement root = new JsonParser().parse(new FileReader("/path/to/the/json/file/in/your/file/system.json"));
//Get the content of the first map
JsonObject object = root.getAsJsonObject().get("shopping_list").getAsJsonObject();
//Iterate over this map
Gson gson = new Gson();
for (Entry<String, JsonElement> entry : object.entrySet())
ShoppingList shoppingList = gson.fromJson(entry.getValue(), ShoppingList.class);
System.out.println(shoppingList.getLabel());
The corresponding POJO should be something like that :
public class ShoppingList
int id;
String label;
boolean current;
int nb_reference;
//Setters & Getters !!!!!
Hope it helps !
add a comment |
This way its works like a Map...
JSONObject fieldsJson = new JSONObject(json);
String value = fieldsJson.getString(key);
<dependency>
<groupId>org.codehaus.jettison</groupId>
<artifactId>jettison</artifactId>
<version>1.1</version>
</dependency>
1
Yes, but you must wrap every single ´get´ in try/catch because of JSON exceptions.
– Maciej Swic
Oct 28 '13 at 9:28
1
you could write a class,JsonMap implements Map<String,Object
to wrap JSONObject. then you get the trueMap
interface.
– Jeffrey Blattman
Jan 16 '14 at 18:54
Please add used libraries.
– mvermand
Jan 22 '18 at 6:56
1
@mvermand Added the dependency I've used back then
– Fabio Araujo
Jan 23 '18 at 11:02
add a comment |
I do it this way. It's Simple.
import java.util.Map;
import org.json.JSONObject;
import com.google.gson.Gson;
public class Main
public static void main(String[] args)
JSONObject jsonObj = new JSONObject(" "f1":"v1"");
@SuppressWarnings("unchecked")
Map<String, String> map = new Gson().fromJson(jsonObj.toString(),Map.class);
System.out.println(map);
add a comment |
java.lang.reflect.Type mapType = new TypeToken<Map<String, Object>>().getType();
Gson gson = new Gson();
Map<String, Object> categoryicons = gson.fromJson(json, mapType );
add a comment |
The JsonTools library is very complete. It can be found at Github.
@zygimantus, corrected the link, added new location.
– Bruno Ranschaert
Oct 6 '16 at 15:22
add a comment |
With google's Gson 2.7 (probably earlier versions too, but I tested 2.7) it's as simple as:
Map map = gson.fromJson(json, Map.class);
Which returns a Map of type class com.google.gson.internal.LinkedTreeMap
and works recursively on nested objects.
add a comment |
One more alternative is json-simple which can be found in Maven Central:
(JSONObject)JSONValue.parse(someString); //JSONObject is actually a Map.
The artifact is 24kbytes, doesn't have other runtime dependencies.
I getnull
back from a simple JSON string where one of the values is an array of strings.
– isapir
Sep 12 '16 at 5:45
add a comment |
import net.sf.json.JSONObject
JSONObject.fromObject(yourJsonString).toMap
add a comment |
Underscore-java library can convert json string to hash map. I am the maintainer of the project.
Code example:
import com.github.underscore.lodash.U;
import java.util.*;
public class Main
@SuppressWarnings("unchecked")
public static void main(String[] args)
String json = ""
+ " "data" :"
+ " "
+ " "field1" : "value1","
+ " "field2" : "value2""
+ " "
+ "";
Map<String, Object> data = (Map) U.get((Map<String, Object>) U.fromJson(json), "data");
System.out.println(data);
// field1=value1, field2=value2
add a comment |
JSON to Map always gonna be a string/object data type. i haved GSON lib from google.
works very well and JDK 1.5 is the min requirement.
1
How did you use GSON?
– NinjaCoder
Jun 8 '15 at 20:08
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f443499%2fconvert-json-to-map%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
14 Answers
14
active
oldest
votes
14 Answers
14
active
oldest
votes
active
oldest
votes
active
oldest
votes
I hope you were joking about writing your own parser. :-)
For such a simple mapping, most tools from http://json.org (section java) would work.
For one of them (Jackson, http://wiki.fasterxml.com/JacksonInFiveMinutes), you'd do:
HashMap<String,Object> result =
new ObjectMapper().readValue(JSON_SOURCE, HashMap.class);
(where JSON_SOURCE is a File, input stream, reader, or json content String)
32
Moreover, if you want a typed Map (exploiting java generics), you can do : Map<String, MyPojo> typedMap = mapper.readValue(jsonStream, new TypeReference<Map<String, MyPojo>>() );
– obe6
Dec 29 '14 at 20:46
3
If you work with Maven project, you will need <dependency> <groupId>com.fasterxml.jackson.core</groupId> <artifactId>jackson-databind</artifactId> <version>2.4.4</version> </dependency>
– LoBo
Nov 2 '15 at 9:49
1
And looks like Jackson has moved since 09 so: Jackson data-bind
– jacob.mccrumb
Sep 21 '16 at 18:42
@obe6 I guess the OP is not joking. Can you find a single "JSON" anywhere in your code snippet other than that arbitrary variable name? I'm struggling too because of the names in Jackson API.
– Aetherus
Nov 22 '18 at 9:39
FWTW, while @obe6's answer is technically correct, you can use shorter form too:Map<String,Object> result = mapper.readValue(source, Map.class)
.
– StaxMan
Nov 28 '18 at 6:40
add a comment |
I hope you were joking about writing your own parser. :-)
For such a simple mapping, most tools from http://json.org (section java) would work.
For one of them (Jackson, http://wiki.fasterxml.com/JacksonInFiveMinutes), you'd do:
HashMap<String,Object> result =
new ObjectMapper().readValue(JSON_SOURCE, HashMap.class);
(where JSON_SOURCE is a File, input stream, reader, or json content String)
32
Moreover, if you want a typed Map (exploiting java generics), you can do : Map<String, MyPojo> typedMap = mapper.readValue(jsonStream, new TypeReference<Map<String, MyPojo>>() );
– obe6
Dec 29 '14 at 20:46
3
If you work with Maven project, you will need <dependency> <groupId>com.fasterxml.jackson.core</groupId> <artifactId>jackson-databind</artifactId> <version>2.4.4</version> </dependency>
– LoBo
Nov 2 '15 at 9:49
1
And looks like Jackson has moved since 09 so: Jackson data-bind
– jacob.mccrumb
Sep 21 '16 at 18:42
@obe6 I guess the OP is not joking. Can you find a single "JSON" anywhere in your code snippet other than that arbitrary variable name? I'm struggling too because of the names in Jackson API.
– Aetherus
Nov 22 '18 at 9:39
FWTW, while @obe6's answer is technically correct, you can use shorter form too:Map<String,Object> result = mapper.readValue(source, Map.class)
.
– StaxMan
Nov 28 '18 at 6:40
add a comment |
I hope you were joking about writing your own parser. :-)
For such a simple mapping, most tools from http://json.org (section java) would work.
For one of them (Jackson, http://wiki.fasterxml.com/JacksonInFiveMinutes), you'd do:
HashMap<String,Object> result =
new ObjectMapper().readValue(JSON_SOURCE, HashMap.class);
(where JSON_SOURCE is a File, input stream, reader, or json content String)
I hope you were joking about writing your own parser. :-)
For such a simple mapping, most tools from http://json.org (section java) would work.
For one of them (Jackson, http://wiki.fasterxml.com/JacksonInFiveMinutes), you'd do:
HashMap<String,Object> result =
new ObjectMapper().readValue(JSON_SOURCE, HashMap.class);
(where JSON_SOURCE is a File, input stream, reader, or json content String)
edited Apr 8 '12 at 0:54
jedwards
22.1k13667
22.1k13667
answered Feb 24 '09 at 21:11
StaxManStaxMan
84.5k26167205
84.5k26167205
32
Moreover, if you want a typed Map (exploiting java generics), you can do : Map<String, MyPojo> typedMap = mapper.readValue(jsonStream, new TypeReference<Map<String, MyPojo>>() );
– obe6
Dec 29 '14 at 20:46
3
If you work with Maven project, you will need <dependency> <groupId>com.fasterxml.jackson.core</groupId> <artifactId>jackson-databind</artifactId> <version>2.4.4</version> </dependency>
– LoBo
Nov 2 '15 at 9:49
1
And looks like Jackson has moved since 09 so: Jackson data-bind
– jacob.mccrumb
Sep 21 '16 at 18:42
@obe6 I guess the OP is not joking. Can you find a single "JSON" anywhere in your code snippet other than that arbitrary variable name? I'm struggling too because of the names in Jackson API.
– Aetherus
Nov 22 '18 at 9:39
FWTW, while @obe6's answer is technically correct, you can use shorter form too:Map<String,Object> result = mapper.readValue(source, Map.class)
.
– StaxMan
Nov 28 '18 at 6:40
add a comment |
32
Moreover, if you want a typed Map (exploiting java generics), you can do : Map<String, MyPojo> typedMap = mapper.readValue(jsonStream, new TypeReference<Map<String, MyPojo>>() );
– obe6
Dec 29 '14 at 20:46
3
If you work with Maven project, you will need <dependency> <groupId>com.fasterxml.jackson.core</groupId> <artifactId>jackson-databind</artifactId> <version>2.4.4</version> </dependency>
– LoBo
Nov 2 '15 at 9:49
1
And looks like Jackson has moved since 09 so: Jackson data-bind
– jacob.mccrumb
Sep 21 '16 at 18:42
@obe6 I guess the OP is not joking. Can you find a single "JSON" anywhere in your code snippet other than that arbitrary variable name? I'm struggling too because of the names in Jackson API.
– Aetherus
Nov 22 '18 at 9:39
FWTW, while @obe6's answer is technically correct, you can use shorter form too:Map<String,Object> result = mapper.readValue(source, Map.class)
.
– StaxMan
Nov 28 '18 at 6:40
32
32
Moreover, if you want a typed Map (exploiting java generics), you can do : Map<String, MyPojo> typedMap = mapper.readValue(jsonStream, new TypeReference<Map<String, MyPojo>>() );
– obe6
Dec 29 '14 at 20:46
Moreover, if you want a typed Map (exploiting java generics), you can do : Map<String, MyPojo> typedMap = mapper.readValue(jsonStream, new TypeReference<Map<String, MyPojo>>() );
– obe6
Dec 29 '14 at 20:46
3
3
If you work with Maven project, you will need <dependency> <groupId>com.fasterxml.jackson.core</groupId> <artifactId>jackson-databind</artifactId> <version>2.4.4</version> </dependency>
– LoBo
Nov 2 '15 at 9:49
If you work with Maven project, you will need <dependency> <groupId>com.fasterxml.jackson.core</groupId> <artifactId>jackson-databind</artifactId> <version>2.4.4</version> </dependency>
– LoBo
Nov 2 '15 at 9:49
1
1
And looks like Jackson has moved since 09 so: Jackson data-bind
– jacob.mccrumb
Sep 21 '16 at 18:42
And looks like Jackson has moved since 09 so: Jackson data-bind
– jacob.mccrumb
Sep 21 '16 at 18:42
@obe6 I guess the OP is not joking. Can you find a single "JSON" anywhere in your code snippet other than that arbitrary variable name? I'm struggling too because of the names in Jackson API.
– Aetherus
Nov 22 '18 at 9:39
@obe6 I guess the OP is not joking. Can you find a single "JSON" anywhere in your code snippet other than that arbitrary variable name? I'm struggling too because of the names in Jackson API.
– Aetherus
Nov 22 '18 at 9:39
FWTW, while @obe6's answer is technically correct, you can use shorter form too:
Map<String,Object> result = mapper.readValue(source, Map.class)
.– StaxMan
Nov 28 '18 at 6:40
FWTW, while @obe6's answer is technically correct, you can use shorter form too:
Map<String,Object> result = mapper.readValue(source, Map.class)
.– StaxMan
Nov 28 '18 at 6:40
add a comment |
I like google gson library.
When you don't know structure of json. You can use
JsonElement root = new JsonParser().parse(jsonString);
and then you can work with json. e.g. how to get "value1" from your gson:
String value1 = root.getAsJsonObject().get("data").getAsJsonObject().get("field1").getAsString();
14
This can throw NullPointerExceptions 5 different ways if you get unexpected data.
– dfraser
Aug 27 '15 at 14:31
i hate the google gson library, it's rubbish
– bharal
Jan 9 at 18:22
add a comment |
I like google gson library.
When you don't know structure of json. You can use
JsonElement root = new JsonParser().parse(jsonString);
and then you can work with json. e.g. how to get "value1" from your gson:
String value1 = root.getAsJsonObject().get("data").getAsJsonObject().get("field1").getAsString();
14
This can throw NullPointerExceptions 5 different ways if you get unexpected data.
– dfraser
Aug 27 '15 at 14:31
i hate the google gson library, it's rubbish
– bharal
Jan 9 at 18:22
add a comment |
I like google gson library.
When you don't know structure of json. You can use
JsonElement root = new JsonParser().parse(jsonString);
and then you can work with json. e.g. how to get "value1" from your gson:
String value1 = root.getAsJsonObject().get("data").getAsJsonObject().get("field1").getAsString();
I like google gson library.
When you don't know structure of json. You can use
JsonElement root = new JsonParser().parse(jsonString);
and then you can work with json. e.g. how to get "value1" from your gson:
String value1 = root.getAsJsonObject().get("data").getAsJsonObject().get("field1").getAsString();
answered Dec 1 '11 at 10:15
bugs_bugs_
2,43432233
2,43432233
14
This can throw NullPointerExceptions 5 different ways if you get unexpected data.
– dfraser
Aug 27 '15 at 14:31
i hate the google gson library, it's rubbish
– bharal
Jan 9 at 18:22
add a comment |
14
This can throw NullPointerExceptions 5 different ways if you get unexpected data.
– dfraser
Aug 27 '15 at 14:31
i hate the google gson library, it's rubbish
– bharal
Jan 9 at 18:22
14
14
This can throw NullPointerExceptions 5 different ways if you get unexpected data.
– dfraser
Aug 27 '15 at 14:31
This can throw NullPointerExceptions 5 different ways if you get unexpected data.
– dfraser
Aug 27 '15 at 14:31
i hate the google gson library, it's rubbish
– bharal
Jan 9 at 18:22
i hate the google gson library, it's rubbish
– bharal
Jan 9 at 18:22
add a comment |
Using the GSON library:
import com.google.gson.Gson;
import com.google.common.reflect.TypeToken;
import java.lang.reclect.Type;
Use the following code:
Type mapType = new TypeToken<Map<String, Map>>().getType();
Map<String, String[]> son = new Gson().fromJson(easyString, mapType);
5
java at its best:TypeToken<Map<String, Map>>
:-)
– froderik
Oct 26 '14 at 8:10
With new TypeToken<Map<String, Object>> it will work also when there are arrays inside.
– 9ilsdx 9rvj 0lo
Jan 10 '18 at 13:19
add a comment |
Using the GSON library:
import com.google.gson.Gson;
import com.google.common.reflect.TypeToken;
import java.lang.reclect.Type;
Use the following code:
Type mapType = new TypeToken<Map<String, Map>>().getType();
Map<String, String[]> son = new Gson().fromJson(easyString, mapType);
5
java at its best:TypeToken<Map<String, Map>>
:-)
– froderik
Oct 26 '14 at 8:10
With new TypeToken<Map<String, Object>> it will work also when there are arrays inside.
– 9ilsdx 9rvj 0lo
Jan 10 '18 at 13:19
add a comment |
Using the GSON library:
import com.google.gson.Gson;
import com.google.common.reflect.TypeToken;
import java.lang.reclect.Type;
Use the following code:
Type mapType = new TypeToken<Map<String, Map>>().getType();
Map<String, String[]> son = new Gson().fromJson(easyString, mapType);
Using the GSON library:
import com.google.gson.Gson;
import com.google.common.reflect.TypeToken;
import java.lang.reclect.Type;
Use the following code:
Type mapType = new TypeToken<Map<String, Map>>().getType();
Map<String, String[]> son = new Gson().fromJson(easyString, mapType);
edited Jan 14 at 13:46
user1170330
6,0852367111
6,0852367111
answered Nov 15 '11 at 6:25
David LDavid L
30732
30732
5
java at its best:TypeToken<Map<String, Map>>
:-)
– froderik
Oct 26 '14 at 8:10
With new TypeToken<Map<String, Object>> it will work also when there are arrays inside.
– 9ilsdx 9rvj 0lo
Jan 10 '18 at 13:19
add a comment |
5
java at its best:TypeToken<Map<String, Map>>
:-)
– froderik
Oct 26 '14 at 8:10
With new TypeToken<Map<String, Object>> it will work also when there are arrays inside.
– 9ilsdx 9rvj 0lo
Jan 10 '18 at 13:19
5
5
java at its best:
TypeToken<Map<String, Map>>
:-)– froderik
Oct 26 '14 at 8:10
java at its best:
TypeToken<Map<String, Map>>
:-)– froderik
Oct 26 '14 at 8:10
With new TypeToken<Map<String, Object>> it will work also when there are arrays inside.
– 9ilsdx 9rvj 0lo
Jan 10 '18 at 13:19
With new TypeToken<Map<String, Object>> it will work also when there are arrays inside.
– 9ilsdx 9rvj 0lo
Jan 10 '18 at 13:19
add a comment |
Use JSON lib E.g. http://www.json.org/java/
// Assume you have a Map<String, String> in JSONObject jdata
@SuppressWarnings("unchecked")
Iterator<String> nameItr = jdata.keys();
Map<String, String> outMap = new HashMap<String, String>();
while(nameItr.hasNext())
String name = nameItr.next();
outMap.put(name, jdata.getString(name));
add a comment |
Use JSON lib E.g. http://www.json.org/java/
// Assume you have a Map<String, String> in JSONObject jdata
@SuppressWarnings("unchecked")
Iterator<String> nameItr = jdata.keys();
Map<String, String> outMap = new HashMap<String, String>();
while(nameItr.hasNext())
String name = nameItr.next();
outMap.put(name, jdata.getString(name));
add a comment |
Use JSON lib E.g. http://www.json.org/java/
// Assume you have a Map<String, String> in JSONObject jdata
@SuppressWarnings("unchecked")
Iterator<String> nameItr = jdata.keys();
Map<String, String> outMap = new HashMap<String, String>();
while(nameItr.hasNext())
String name = nameItr.next();
outMap.put(name, jdata.getString(name));
Use JSON lib E.g. http://www.json.org/java/
// Assume you have a Map<String, String> in JSONObject jdata
@SuppressWarnings("unchecked")
Iterator<String> nameItr = jdata.keys();
Map<String, String> outMap = new HashMap<String, String>();
while(nameItr.hasNext())
String name = nameItr.next();
outMap.put(name, jdata.getString(name));
edited Jan 14 '15 at 16:58
El Marce
1,61911432
1,61911432
answered Nov 10 '10 at 22:02
j.d.j.d.
16112
16112
add a comment |
add a comment |
My post could be helpful for others, so imagine you have a map with a specific object in values, something like that:
"shopping_list":
"996386":
"id":996386,
"label":"My 1st shopping list",
"current":true,
"nb_reference":6
,
"888540":
"id":888540,
"label":"My 2nd shopping list",
"current":false,
"nb_reference":2
To parse this JSON file with GSON library, it's easy :
if your project is mavenized
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.3.1</version>
</dependency>
Then use this snippet :
import com.google.gson.Gson;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
//Read the JSON file
JsonElement root = new JsonParser().parse(new FileReader("/path/to/the/json/file/in/your/file/system.json"));
//Get the content of the first map
JsonObject object = root.getAsJsonObject().get("shopping_list").getAsJsonObject();
//Iterate over this map
Gson gson = new Gson();
for (Entry<String, JsonElement> entry : object.entrySet())
ShoppingList shoppingList = gson.fromJson(entry.getValue(), ShoppingList.class);
System.out.println(shoppingList.getLabel());
The corresponding POJO should be something like that :
public class ShoppingList
int id;
String label;
boolean current;
int nb_reference;
//Setters & Getters !!!!!
Hope it helps !
add a comment |
My post could be helpful for others, so imagine you have a map with a specific object in values, something like that:
"shopping_list":
"996386":
"id":996386,
"label":"My 1st shopping list",
"current":true,
"nb_reference":6
,
"888540":
"id":888540,
"label":"My 2nd shopping list",
"current":false,
"nb_reference":2
To parse this JSON file with GSON library, it's easy :
if your project is mavenized
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.3.1</version>
</dependency>
Then use this snippet :
import com.google.gson.Gson;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
//Read the JSON file
JsonElement root = new JsonParser().parse(new FileReader("/path/to/the/json/file/in/your/file/system.json"));
//Get the content of the first map
JsonObject object = root.getAsJsonObject().get("shopping_list").getAsJsonObject();
//Iterate over this map
Gson gson = new Gson();
for (Entry<String, JsonElement> entry : object.entrySet())
ShoppingList shoppingList = gson.fromJson(entry.getValue(), ShoppingList.class);
System.out.println(shoppingList.getLabel());
The corresponding POJO should be something like that :
public class ShoppingList
int id;
String label;
boolean current;
int nb_reference;
//Setters & Getters !!!!!
Hope it helps !
add a comment |
My post could be helpful for others, so imagine you have a map with a specific object in values, something like that:
"shopping_list":
"996386":
"id":996386,
"label":"My 1st shopping list",
"current":true,
"nb_reference":6
,
"888540":
"id":888540,
"label":"My 2nd shopping list",
"current":false,
"nb_reference":2
To parse this JSON file with GSON library, it's easy :
if your project is mavenized
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.3.1</version>
</dependency>
Then use this snippet :
import com.google.gson.Gson;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
//Read the JSON file
JsonElement root = new JsonParser().parse(new FileReader("/path/to/the/json/file/in/your/file/system.json"));
//Get the content of the first map
JsonObject object = root.getAsJsonObject().get("shopping_list").getAsJsonObject();
//Iterate over this map
Gson gson = new Gson();
for (Entry<String, JsonElement> entry : object.entrySet())
ShoppingList shoppingList = gson.fromJson(entry.getValue(), ShoppingList.class);
System.out.println(shoppingList.getLabel());
The corresponding POJO should be something like that :
public class ShoppingList
int id;
String label;
boolean current;
int nb_reference;
//Setters & Getters !!!!!
Hope it helps !
My post could be helpful for others, so imagine you have a map with a specific object in values, something like that:
"shopping_list":
"996386":
"id":996386,
"label":"My 1st shopping list",
"current":true,
"nb_reference":6
,
"888540":
"id":888540,
"label":"My 2nd shopping list",
"current":false,
"nb_reference":2
To parse this JSON file with GSON library, it's easy :
if your project is mavenized
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.3.1</version>
</dependency>
Then use this snippet :
import com.google.gson.Gson;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
//Read the JSON file
JsonElement root = new JsonParser().parse(new FileReader("/path/to/the/json/file/in/your/file/system.json"));
//Get the content of the first map
JsonObject object = root.getAsJsonObject().get("shopping_list").getAsJsonObject();
//Iterate over this map
Gson gson = new Gson();
for (Entry<String, JsonElement> entry : object.entrySet())
ShoppingList shoppingList = gson.fromJson(entry.getValue(), ShoppingList.class);
System.out.println(shoppingList.getLabel());
The corresponding POJO should be something like that :
public class ShoppingList
int id;
String label;
boolean current;
int nb_reference;
//Setters & Getters !!!!!
Hope it helps !
answered Aug 18 '15 at 7:46
Jad B.Jad B.
1,1271214
1,1271214
add a comment |
add a comment |
This way its works like a Map...
JSONObject fieldsJson = new JSONObject(json);
String value = fieldsJson.getString(key);
<dependency>
<groupId>org.codehaus.jettison</groupId>
<artifactId>jettison</artifactId>
<version>1.1</version>
</dependency>
1
Yes, but you must wrap every single ´get´ in try/catch because of JSON exceptions.
– Maciej Swic
Oct 28 '13 at 9:28
1
you could write a class,JsonMap implements Map<String,Object
to wrap JSONObject. then you get the trueMap
interface.
– Jeffrey Blattman
Jan 16 '14 at 18:54
Please add used libraries.
– mvermand
Jan 22 '18 at 6:56
1
@mvermand Added the dependency I've used back then
– Fabio Araujo
Jan 23 '18 at 11:02
add a comment |
This way its works like a Map...
JSONObject fieldsJson = new JSONObject(json);
String value = fieldsJson.getString(key);
<dependency>
<groupId>org.codehaus.jettison</groupId>
<artifactId>jettison</artifactId>
<version>1.1</version>
</dependency>
1
Yes, but you must wrap every single ´get´ in try/catch because of JSON exceptions.
– Maciej Swic
Oct 28 '13 at 9:28
1
you could write a class,JsonMap implements Map<String,Object
to wrap JSONObject. then you get the trueMap
interface.
– Jeffrey Blattman
Jan 16 '14 at 18:54
Please add used libraries.
– mvermand
Jan 22 '18 at 6:56
1
@mvermand Added the dependency I've used back then
– Fabio Araujo
Jan 23 '18 at 11:02
add a comment |
This way its works like a Map...
JSONObject fieldsJson = new JSONObject(json);
String value = fieldsJson.getString(key);
<dependency>
<groupId>org.codehaus.jettison</groupId>
<artifactId>jettison</artifactId>
<version>1.1</version>
</dependency>
This way its works like a Map...
JSONObject fieldsJson = new JSONObject(json);
String value = fieldsJson.getString(key);
<dependency>
<groupId>org.codehaus.jettison</groupId>
<artifactId>jettison</artifactId>
<version>1.1</version>
</dependency>
edited Jan 23 '18 at 11:00
answered Jan 4 '12 at 11:22
Fabio AraujoFabio Araujo
11127
11127
1
Yes, but you must wrap every single ´get´ in try/catch because of JSON exceptions.
– Maciej Swic
Oct 28 '13 at 9:28
1
you could write a class,JsonMap implements Map<String,Object
to wrap JSONObject. then you get the trueMap
interface.
– Jeffrey Blattman
Jan 16 '14 at 18:54
Please add used libraries.
– mvermand
Jan 22 '18 at 6:56
1
@mvermand Added the dependency I've used back then
– Fabio Araujo
Jan 23 '18 at 11:02
add a comment |
1
Yes, but you must wrap every single ´get´ in try/catch because of JSON exceptions.
– Maciej Swic
Oct 28 '13 at 9:28
1
you could write a class,JsonMap implements Map<String,Object
to wrap JSONObject. then you get the trueMap
interface.
– Jeffrey Blattman
Jan 16 '14 at 18:54
Please add used libraries.
– mvermand
Jan 22 '18 at 6:56
1
@mvermand Added the dependency I've used back then
– Fabio Araujo
Jan 23 '18 at 11:02
1
1
Yes, but you must wrap every single ´get´ in try/catch because of JSON exceptions.
– Maciej Swic
Oct 28 '13 at 9:28
Yes, but you must wrap every single ´get´ in try/catch because of JSON exceptions.
– Maciej Swic
Oct 28 '13 at 9:28
1
1
you could write a class,
JsonMap implements Map<String,Object
to wrap JSONObject. then you get the true Map
interface.– Jeffrey Blattman
Jan 16 '14 at 18:54
you could write a class,
JsonMap implements Map<String,Object
to wrap JSONObject. then you get the true Map
interface.– Jeffrey Blattman
Jan 16 '14 at 18:54
Please add used libraries.
– mvermand
Jan 22 '18 at 6:56
Please add used libraries.
– mvermand
Jan 22 '18 at 6:56
1
1
@mvermand Added the dependency I've used back then
– Fabio Araujo
Jan 23 '18 at 11:02
@mvermand Added the dependency I've used back then
– Fabio Araujo
Jan 23 '18 at 11:02
add a comment |
I do it this way. It's Simple.
import java.util.Map;
import org.json.JSONObject;
import com.google.gson.Gson;
public class Main
public static void main(String[] args)
JSONObject jsonObj = new JSONObject(" "f1":"v1"");
@SuppressWarnings("unchecked")
Map<String, String> map = new Gson().fromJson(jsonObj.toString(),Map.class);
System.out.println(map);
add a comment |
I do it this way. It's Simple.
import java.util.Map;
import org.json.JSONObject;
import com.google.gson.Gson;
public class Main
public static void main(String[] args)
JSONObject jsonObj = new JSONObject(" "f1":"v1"");
@SuppressWarnings("unchecked")
Map<String, String> map = new Gson().fromJson(jsonObj.toString(),Map.class);
System.out.println(map);
add a comment |
I do it this way. It's Simple.
import java.util.Map;
import org.json.JSONObject;
import com.google.gson.Gson;
public class Main
public static void main(String[] args)
JSONObject jsonObj = new JSONObject(" "f1":"v1"");
@SuppressWarnings("unchecked")
Map<String, String> map = new Gson().fromJson(jsonObj.toString(),Map.class);
System.out.println(map);
I do it this way. It's Simple.
import java.util.Map;
import org.json.JSONObject;
import com.google.gson.Gson;
public class Main
public static void main(String[] args)
JSONObject jsonObj = new JSONObject(" "f1":"v1"");
@SuppressWarnings("unchecked")
Map<String, String> map = new Gson().fromJson(jsonObj.toString(),Map.class);
System.out.println(map);
edited Apr 5 '18 at 5:45
answered Aug 31 '17 at 12:57
PavanPavan
466
466
add a comment |
add a comment |
java.lang.reflect.Type mapType = new TypeToken<Map<String, Object>>().getType();
Gson gson = new Gson();
Map<String, Object> categoryicons = gson.fromJson(json, mapType );
add a comment |
java.lang.reflect.Type mapType = new TypeToken<Map<String, Object>>().getType();
Gson gson = new Gson();
Map<String, Object> categoryicons = gson.fromJson(json, mapType );
add a comment |
java.lang.reflect.Type mapType = new TypeToken<Map<String, Object>>().getType();
Gson gson = new Gson();
Map<String, Object> categoryicons = gson.fromJson(json, mapType );
java.lang.reflect.Type mapType = new TypeToken<Map<String, Object>>().getType();
Gson gson = new Gson();
Map<String, Object> categoryicons = gson.fromJson(json, mapType );
answered Aug 13 '14 at 14:10
newMaziarnewMaziar
311
311
add a comment |
add a comment |
The JsonTools library is very complete. It can be found at Github.
@zygimantus, corrected the link, added new location.
– Bruno Ranschaert
Oct 6 '16 at 15:22
add a comment |
The JsonTools library is very complete. It can be found at Github.
@zygimantus, corrected the link, added new location.
– Bruno Ranschaert
Oct 6 '16 at 15:22
add a comment |
The JsonTools library is very complete. It can be found at Github.
The JsonTools library is very complete. It can be found at Github.
edited Oct 6 '16 at 15:22
answered Feb 14 '09 at 10:06
Bruno RanschaertBruno Ranschaert
4,12643142
4,12643142
@zygimantus, corrected the link, added new location.
– Bruno Ranschaert
Oct 6 '16 at 15:22
add a comment |
@zygimantus, corrected the link, added new location.
– Bruno Ranschaert
Oct 6 '16 at 15:22
@zygimantus, corrected the link, added new location.
– Bruno Ranschaert
Oct 6 '16 at 15:22
@zygimantus, corrected the link, added new location.
– Bruno Ranschaert
Oct 6 '16 at 15:22
add a comment |
With google's Gson 2.7 (probably earlier versions too, but I tested 2.7) it's as simple as:
Map map = gson.fromJson(json, Map.class);
Which returns a Map of type class com.google.gson.internal.LinkedTreeMap
and works recursively on nested objects.
add a comment |
With google's Gson 2.7 (probably earlier versions too, but I tested 2.7) it's as simple as:
Map map = gson.fromJson(json, Map.class);
Which returns a Map of type class com.google.gson.internal.LinkedTreeMap
and works recursively on nested objects.
add a comment |
With google's Gson 2.7 (probably earlier versions too, but I tested 2.7) it's as simple as:
Map map = gson.fromJson(json, Map.class);
Which returns a Map of type class com.google.gson.internal.LinkedTreeMap
and works recursively on nested objects.
With google's Gson 2.7 (probably earlier versions too, but I tested 2.7) it's as simple as:
Map map = gson.fromJson(json, Map.class);
Which returns a Map of type class com.google.gson.internal.LinkedTreeMap
and works recursively on nested objects.
answered Sep 12 '16 at 5:51
isapirisapir
8,14864970
8,14864970
add a comment |
add a comment |
One more alternative is json-simple which can be found in Maven Central:
(JSONObject)JSONValue.parse(someString); //JSONObject is actually a Map.
The artifact is 24kbytes, doesn't have other runtime dependencies.
I getnull
back from a simple JSON string where one of the values is an array of strings.
– isapir
Sep 12 '16 at 5:45
add a comment |
One more alternative is json-simple which can be found in Maven Central:
(JSONObject)JSONValue.parse(someString); //JSONObject is actually a Map.
The artifact is 24kbytes, doesn't have other runtime dependencies.
I getnull
back from a simple JSON string where one of the values is an array of strings.
– isapir
Sep 12 '16 at 5:45
add a comment |
One more alternative is json-simple which can be found in Maven Central:
(JSONObject)JSONValue.parse(someString); //JSONObject is actually a Map.
The artifact is 24kbytes, doesn't have other runtime dependencies.
One more alternative is json-simple which can be found in Maven Central:
(JSONObject)JSONValue.parse(someString); //JSONObject is actually a Map.
The artifact is 24kbytes, doesn't have other runtime dependencies.
answered Mar 18 '16 at 10:58
pcjuzerpcjuzer
1,80432030
1,80432030
I getnull
back from a simple JSON string where one of the values is an array of strings.
– isapir
Sep 12 '16 at 5:45
add a comment |
I getnull
back from a simple JSON string where one of the values is an array of strings.
– isapir
Sep 12 '16 at 5:45
I get
null
back from a simple JSON string where one of the values is an array of strings.– isapir
Sep 12 '16 at 5:45
I get
null
back from a simple JSON string where one of the values is an array of strings.– isapir
Sep 12 '16 at 5:45
add a comment |
import net.sf.json.JSONObject
JSONObject.fromObject(yourJsonString).toMap
add a comment |
import net.sf.json.JSONObject
JSONObject.fromObject(yourJsonString).toMap
add a comment |
import net.sf.json.JSONObject
JSONObject.fromObject(yourJsonString).toMap
import net.sf.json.JSONObject
JSONObject.fromObject(yourJsonString).toMap
answered Oct 26 '17 at 7:00
Li RaoLi Rao
1112
1112
add a comment |
add a comment |
Underscore-java library can convert json string to hash map. I am the maintainer of the project.
Code example:
import com.github.underscore.lodash.U;
import java.util.*;
public class Main
@SuppressWarnings("unchecked")
public static void main(String[] args)
String json = ""
+ " "data" :"
+ " "
+ " "field1" : "value1","
+ " "field2" : "value2""
+ " "
+ "";
Map<String, Object> data = (Map) U.get((Map<String, Object>) U.fromJson(json), "data");
System.out.println(data);
// field1=value1, field2=value2
add a comment |
Underscore-java library can convert json string to hash map. I am the maintainer of the project.
Code example:
import com.github.underscore.lodash.U;
import java.util.*;
public class Main
@SuppressWarnings("unchecked")
public static void main(String[] args)
String json = ""
+ " "data" :"
+ " "
+ " "field1" : "value1","
+ " "field2" : "value2""
+ " "
+ "";
Map<String, Object> data = (Map) U.get((Map<String, Object>) U.fromJson(json), "data");
System.out.println(data);
// field1=value1, field2=value2
add a comment |
Underscore-java library can convert json string to hash map. I am the maintainer of the project.
Code example:
import com.github.underscore.lodash.U;
import java.util.*;
public class Main
@SuppressWarnings("unchecked")
public static void main(String[] args)
String json = ""
+ " "data" :"
+ " "
+ " "field1" : "value1","
+ " "field2" : "value2""
+ " "
+ "";
Map<String, Object> data = (Map) U.get((Map<String, Object>) U.fromJson(json), "data");
System.out.println(data);
// field1=value1, field2=value2
Underscore-java library can convert json string to hash map. I am the maintainer of the project.
Code example:
import com.github.underscore.lodash.U;
import java.util.*;
public class Main
@SuppressWarnings("unchecked")
public static void main(String[] args)
String json = ""
+ " "data" :"
+ " "
+ " "field1" : "value1","
+ " "field2" : "value2""
+ " "
+ "";
Map<String, Object> data = (Map) U.get((Map<String, Object>) U.fromJson(json), "data");
System.out.println(data);
// field1=value1, field2=value2
edited Sep 28 '18 at 0:21
answered Jan 10 '16 at 15:01
Valentyn KolesnikovValentyn Kolesnikov
602813
602813
add a comment |
add a comment |
JSON to Map always gonna be a string/object data type. i haved GSON lib from google.
works very well and JDK 1.5 is the min requirement.
1
How did you use GSON?
– NinjaCoder
Jun 8 '15 at 20:08
add a comment |
JSON to Map always gonna be a string/object data type. i haved GSON lib from google.
works very well and JDK 1.5 is the min requirement.
1
How did you use GSON?
– NinjaCoder
Jun 8 '15 at 20:08
add a comment |
JSON to Map always gonna be a string/object data type. i haved GSON lib from google.
works very well and JDK 1.5 is the min requirement.
JSON to Map always gonna be a string/object data type. i haved GSON lib from google.
works very well and JDK 1.5 is the min requirement.
answered Jun 12 '09 at 16:03
sadhasivam
1
How did you use GSON?
– NinjaCoder
Jun 8 '15 at 20:08
add a comment |
1
How did you use GSON?
– NinjaCoder
Jun 8 '15 at 20:08
1
1
How did you use GSON?
– NinjaCoder
Jun 8 '15 at 20:08
How did you use GSON?
– NinjaCoder
Jun 8 '15 at 20:08
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f443499%2fconvert-json-to-map%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
I have written code for this without using any library. stackoverflow.com/questions/21720759/jsonobject-to-map/…
– Vikas Gupta
Oct 31 '14 at 9:43