This week's book giveaways are in the Jython/Python and Object-Oriented programming forums.
We're giving away four copies each of Machine Learning for Business: Using Amazon SageMaker and Jupyter and Object Design Style Guide and have the authors on-line!
See this thread and this one for details.
Win a copy of Machine Learning for Business: Using Amazon SageMaker and JupyterE this week in the Jython/Python forum
or Object Design Style Guide in the Object-Oriented programming forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Paul Clapham
  • Jeanne Boyarsky
  • Knute Snortum
Sheriffs:
  • Liutauras Vilda
  • Tim Cooke
  • Junilu Lacar
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Joe Ess
  • salvin francis
  • fred rosenberger

Filtering object arrays based on uniqueValues

 
Ranch Hand
Posts: 644
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have an array of objects that needs to be filtered. The object structure is like below:


and the array will have 50/60 of such objects in the array like below.

I need to have something like this in order to display it on GUI. Separate out array based on their group name. Since Group names are going to be unique but each group can have multiple choices under it.

So I want to create multiple HashMaps that has key as the Group name and Value as the Name.

how can I achieve this using array functions or I need to have a separate logic to create a hashmap?

thanks,
 
Saloon Keeper
Posts: 11189
244
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't know if what you posted was intended to be JSON, but it's not a valid sequence of objects. Use square brackets for lists and separare the elements with commas.

Where are you performing the transformation? On the client side? If on the server side, what language are you using?

If you need to transform it on the server side with Java, you can easily do this with a collector:
 
Tell me how it all turns out. Here is a tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!