Hello everyone,
How do I get a specific value in json text in java ?
Example -
Like json text is -
{
"first" : "1st",
"second" : "2nd"
}
So, how do I get the value for second ?
Hello everyone,
How do I get a specific value in json text in java ?
Example -
Like json text is -
{
"first" : "1st",
"second" : "2nd"
}
So, how do I get the value for second ?
try a Google search next time
https://www.google.com/search?client=firefox-b-d&q=how+to+get+value+from+json+array+in+java
Taifun
You can use JSONObject
Wrong (ethically)!
This is the correct solution:
Ahh... Confused between array and object
Still wrong.
Well Wait....
JSONObject jo = new JSONObject(JSON_STRING);
String second = jo.getString("second");
couldn't it can be done like this?
Yeah that's right.
However let him search somewhere before asking here for help.
Thanks every1 for their reply. I'll test it and tell if I'm successful or not.
You can also use built in block called "dictionary" for Parse JSON object
Yes, it is important to encourage people to use the tools to find the information they need. However, I don't think this was the most appropriate way to do it and @Techno_Vedang's response was valid.