0

I have used the OpenSearch API as suggested here.

The result I get, as shown in a solution in that page, is of this form:

[
   "Malleshwaram",
   ["Malleshwaram"],
   [""],
   ["https:\/\/en.wikipedia.org\/wiki\/Malleshwaram"]
]

Now I have collected this in a JSONArray object (org.json). But I am unable to parse it since there is no key in these key value pairs. How do I get the elements by their indices?

I just wanted to separate these elements and store them in different string arrays.

halfer
  • 19,824
  • 17
  • 99
  • 186
SoulRayder
  • 5,072
  • 6
  • 47
  • 93
  • It's hard to know what you are asking when you are not even specifying the language. Are you looking for http://stackoverflow.com/questions/3010840/loop-through-array-in-javascript ? – Tgr Nov 28 '15 at 23:21
  • I had added java as a tag when I created this post :) Anyways, I solved my problem, thank you :) – SoulRayder Nov 29 '15 at 06:08

1 Answers1

0

The sample JSON you posted is a single-dimensional array of mixed data types: a string, and three string arrays. It might be easier to make a two-dimensional array of Objects, and use appropriate accessors to return the values you're looking for, implemented in a way that accounts for what the possible JSON responses could be if there is more than one URL returned, etc.

champbell
  • 31
  • 2