-1

My application makes API calls and receives data in a single string. The data looks something like this: [{"city_mpg": 16, "cylinders": 6, "displacement": 2.8}]

My plan was to extract data from this string and assign it to variables ex. var cylinders = 6

Is that even possible?

EDIT:

After following this post I solved the problem with ease. Turns out i was looking at it wrong.

1
  • My plan was to extract data from this string and assign it to variables ex. var cylinders = 6 can you show how you tried to do this ? could it be that this data is perhaps using a common format, like Json, which you could parse and make your life simpler ? I tried using .contains() but to no avail. what does contains do ? how did you try to use that to solve your problem here ? Commented Nov 28, 2023 at 13:14

1 Answer 1

-1

This string is in JSON format. To extract data to variables use something like GSON, which is a library build for deserialising json strings into objects. For a detailed description, on how to use GSON please check out this link or this Stack Overflow question about the same issue.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.