Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within Open Source Projects
Search Coderanch
Advance search
Google search
Register / Login
Post Reply
Bookmark Topic
Watch Topic
New Topic
programming forums
Java
Mobile
Certification
Databases
Caching
Books
Engineering
Micro Controllers
OS
Languages
Paradigms
IDEs
Build Tools
Frameworks
Application Servers
Open Source
This Site
Careers
Other
Pie Elite
all forums
this forum made possible by our volunteer staff, including ...
Marshals:
Campbell Ritchie
Jeanne Boyarsky
Ron McLeod
Paul Clapham
Liutauras Vilda
Sheriffs:
paul wheaton
Rob Spoor
Devaka Cooray
Saloon Keepers:
Stephan van Hulst
Tim Holloway
Carey Brown
Frits Walraven
Tim Moores
Bartenders:
Mikalai Zaikin
Forum:
Other Open Source Projects
Need some help parsing JSON to Java using GSON.
Nikolas Nikolaou
Ranch Hand
Posts: 101
1
posted 7 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Hi.
I'm trying to pass the following code from JSON to
JAVA
:
{"boxid00E04C694247":{"credentials":{"username":"admin@wlnet","password":"1Kdds24"},"routes":["192.168.0.0/24","192.168.8.0/24"]},"boxid0CC47A69CF80":{"credentials":{"username":"admin2@wlnet","password":"n8gdd2"},"routes":["192.168.10.0/24","192.168.20.0/24"]}}
I would like for each boxid .. to be parsed Into the relevant credentials/routes.
Should I be converting this specific JSON format to a two dimensional Array for each boxid ?
Bear Bibeault
Sheriff
Posts: 67746
173
I like...
posted 7 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
2D array? Why? The JSON specifies a list of strings for the route.
For future posts, please format the JSON across multiple lines rather than one single and long line.
[
Asking smart questions
] [
About Bear
] [
Books by Bear
]
Nikolas Nikolaou
Ranch Hand
Posts: 101
1
posted 7 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Hi. Thanks for the reply.
I only learned about JSON a few days ago and am trying to grasp the syntax / parsing process.
As mentioned earlier, I need to retrieve the routes for a specific boxID. A list of boxID's will be retrieved from a serve In the format below.
So far, the Info I am finding Involves creating classes with predefined strings/arrays etc and loading these values from JSON to the JAVA class.
I cannot do this as I will be downloading Info on the fly.
What would be the best procedure to Just retrieve the required values as Strings/Arrays ?
{"boxID00E04C694247":{ "credentials": {"username":"admin@wlnet","password":"1Kdds24"}, "routes":["192.168.0.0/24","192.168.8.0/24"]}, "boxID0CC47A69CF80":{ "credentials": {"username":"admin2@wlnet","password":"n8gdd2"}, "routes":["192.168.10.0/24","192.168.20.0/24"]}}
Nikolas Nikolaou
Ranch Hand
Posts: 101
1
posted 7 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
To sum it up, I basically need help parsing the data when the fields will be unknown.
I can't create predefined strings / arrays.
Don't get me started about those stupid
light bulbs
.
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
Passing a JSF dataTable into a javascript chart for rendering
deserialize JSONArray with GSON
Strip slashes
Configure spring controller to return json response
HashMaps
More...