• 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

Drill Down On Object Array

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am learning java and am hitting an API and returning data in this format


The code I am using to produce this is



Now my question is, I am using gson to handle json in my javafx project - how do I return this criterie only?

I want to return
 
Saloon Keeper
Posts: 15524
364
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Welcome to CodeRanch!

Well, can't you access the content object directly? What does its class look like?

P.S. I recommend using JSON-B rather than GSON.
 
Maestro Smith
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Stephan thank you for the response!

I went with gson as I saw many tutorials on google for how to use it - I will have to give JSON-B a look also.

I am not clear on exactly what you are asking, what do I need to show you?

Sorry, I have only been coding with java for about 3 weeks so I am still learning a lot.
 
Stephan van Hulst
Saloon Keeper
Posts: 15524
364
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well, you have a content variable that you turn into JSON. So can't you just access content.student, content.emails, etc.?

Did you mean that the content variable is part of a web service, and you're sending it as JSON to your client application first? Then you need to deserialize the JSON back to a Java object. You can very easily do this if you use JSON-B and your JSON classes are part of a shared library.

What framework are you using for the web service? Can you show us the class that sends the JSON to your client application?
 
reply
    Bookmark Topic Watch Topic
  • New Topic