0

I have a dictionary on a website in form of json which looks for example like this:

"types":[{
    "id":"0",
    "name":"value1"
    },{
    "id":"1",
    "name":"value2"
    },{
    "id":"2",
    "name":"value3"
    }]

I cant find any useful example of a method that could help me retrieve that information and put it in, for example, a string array. Maybe anyone of you come across same problem please help!

P.S. I tried method like simplest way to read json from a URL in java with no success.

Community
  • 1
  • 1
Mithrand1r
  • 2,313
  • 9
  • 37
  • 76
  • http://stackoverflow.com/questions/5911558/java-deserializing-json-structure-to-mapstring-object?rq=1 doesn't help? – Kheldar Oct 14 '12 at 08:41
  • 1
    it loos like i am not smart enough to make use of link you have privided, i do not see any connection between those two topics.. – Mithrand1r Oct 14 '12 at 08:48
  • It looks to me that your question is then unrelated to your problem. Your comment to Quoi's appropriate answer, which is very similar to the one in the link I gave, shows it also. I'd advise you give more information if you expect people to be able to help you. – Kheldar Oct 15 '12 at 10:50

1 Answers1

0

It is array of json object value whose key is types. You can use json-java library like gson, jackson,flexjson etc.. to parse this json object and achieve your required result.

GSON Example -

JsonElement jElement = new JsonParser().parse(jsonString);
JsonObject  jObject = jElement.getAsJsonObject();
jObject = jObject.getAsJsonObject("types");

Or you can use pojo class like -

public class Type {
  private int id;
  private String name;
  ...
}

gson.fromJson(jsonString, Type.class);

Refer java docs.

Subhrajyoti Majumder
  • 40,646
  • 13
  • 77
  • 103
  • quoi thanks for your relpy, mian problem is that i can't read jsonString, i believe it is beacause of link under which it is *.jsp – Mithrand1r Oct 14 '12 at 09:18