0

Hello i have a new problem today i need to construct an object like that with this particular strucural (i have made changes):

{ 
 principalid:
 {
 id:1
  { 
  price1:20,
  price2:30,
  price3:30
  secondaryid:
  { 
  subId:1 
   {
   price1:60,
   price2:80,
   price3:120
    thirdid:
    { 
     subsubId:1 
     {
     price1:60,
     price2:80,
     price3:120
     }
     subsubId:2 {
     price1:60,
     price2:80,
     price3:120
     }
     }}}}

I have my java object named Price with getter and setter

public class Price {

private Double price1 = null;
private Double price2 = null;
private Double price3 = null;
}

To create the first level, i used to declare a new attribute in my Object something like :

    private final Map<String, Price> mapPrice = new HashMap<>();

Where String represents Id but i want use same for subid and subsubId

How can i do to organise my object with multiple sub level ?

Do you have any suggestion or any sample to implement this solutions ?

Thanks

Lionel B
  • 1,172
  • 2
  • 9
  • 24

1 Answers1

-1

Your data seems to be json, so you might want to take a look at JsonObject and it's use.

And/or a look at gson.

Mykong has a short guide.

Gunnar
  • 383
  • 4
  • 18
  • This is just a common notation to represent data structure. Nothing in the question show that this is actually the JSON notation. – AxelH Jan 27 '17 at 13:51
  • I know how to convert to Json, it's just for represents my idea, i want to know the Java code structure – Lionel B Jan 27 '17 at 13:51