Join Carlos Rivas for an in-depth discussion in this video Parsing the location data, part of Code Clinic: Java.
- [Instructor] Now that we're familiar…with the JSON structure that we'll be using,…let's go ahead and add our test case and run our program.…We'll go to the main method, where we can see we have…declared the three variables that we're going to be using.…Location, which will hold…our JSON document in the string format.…Objects, which is a JSON object…that will hold the locations once it's parsed.…And map link, which is the URL…that we're going to use to link to our map.…
Let's write our test case now.…We're calling get data and storing…the value in our location string.…In this case, we will not be passing any input parameter,…so that it will take our current IP address.…Next, we'll create a new instance of our JSON object,…using this input, the location we just acquired.…With this data, we can proceed to gather our desired fields.…
In this case, city and country.…So let's output our desired values.…We'll do that by printing a message first,…saying you are in or near the city of.…And then go to our JSON object…and call the get string method to get the city value.…
Visit other courses in the series to see how to solve the exact same challenges in languages like C#, C++, PHP, Python, and Ruby.
Skill Level Intermediate
1. Problem 1: Pond Oreille
2. Problem 2: Where Am I?
3. Problem 3: Eight Queens
4. Problem 4: Accessing Peripherals
5. Problem 5: Facial Recognition
6. Problem 6: Real-Time Information Dashboard
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.