0

I am trying to parse and get the output given to me by a HTTP response that looks similar to this and is in a string I named 'line'. (the response contents change every time it runs)

{"needle":"opuwyxib"," haystack":["igrnevcp","ripfxjuv","amjctpsr","ucdpotrj","usqhrmvz","jblhmqgx","opuwyxib","mbhfylwt","ltkvhjsw","dhnpaurg","muyesbcg","etxmvzyd","chyfigmd","udskerov","ngoqzmve","ukeljaqw","dngqmtrz","xztpbjfs","zgdrcnbp","tkfivrld"]}

how do I extract this using Gson then use the extraction to find the index of the needle?

Cœur
  • 37,241
  • 25
  • 195
  • 267
  • If the response content changes, then how are you expected to parse the data? Or, do you mean `haystack` changes? – OneCricketeer Nov 04 '16 at 21:00
  • needle and haystack as a key stay the same but the values change constantly – Eugene Kyere Nov 05 '16 at 01:10
  • Alright, then if you deserialize Gson to a JSON object, then should be easy to extract both the haystack string list and the needle string value. The Arraylist class has an indexOf method that may prove useful to you – OneCricketeer Nov 05 '16 at 01:42

0 Answers0