robohorse / RoboPOJOGenerator

IntelliJ IDEA and Android Studio plugin
MIT License
718 stars 83 forks source link

Function: Support create single file with static inner classes #60

Open sonvp opened 7 years ago

sonvp commented 7 years ago

Hi @robohorse . Instead of create separate file for each object. I want to output only one class object like the example below.

{
  "ongoing": {
    "frequency": "123",
    "weekTime": [
      [
        "Week 1 Wed 10:00am-12:00pm"
      ],
      [
        "Week 2 Thu 07:30am-09:30am"
      ]
    ]
  }
}
               |
               |
               |
               V

public class Test{

    private Ongoing ongoing;

    public static class Ongoing{
        private List<List<String>> weekTime;
        private String frequency;
    }
}

Can you support function above. Thank

robohorse commented 7 years ago

hmm...

cgoodroe commented 7 years ago

+1, personally interested in this combined with kotlin data classes

billybong commented 7 years ago

+1 for Kotlin data classes in one file. Thats how I generally create JSON domain classes due to Kotlins brevity.

wallezhang commented 5 years ago

+1 😄

schrek1 commented 5 years ago

+1 and insert generated code to selected place

slankka commented 4 months ago

+1 It is annoying to create pojos for multi-depths structure json. .

For example: a trend data graph json
{
        "label": "vcpu/vmem/ssd/ssdb/hdd",
        "unit": "Core/GB/TiB/TiB/TiB",
        "graph": {
           "time": [ 1719108000000,  1719194400000],
           "regions": ["yz"," jsy"],
           "series": ["Independent", "Dedicated"],
           "values": [
                 { 
                  "region": "yz",
                   "datas": [ {
                      "type": "Independent", 
                      "total": [ 5,  5 ],
                      "daily": [ 5, 5],
                      "released": [ 5,5  ]
                    },
                    {
                      "type": "Dedicated", 
                      "total": [ 5,  5 ],
                      "daily": [ 5, 5],
                      "released": [ 5,5  ]
                    }
                  ]
                },
                { 
                  "region": "jsy",
                   "datas": [ {
                      "type": "Independent", 
                      "total": [ 5,  5 ],
                      "daily": [ 5, 5],
                      "released": [ 5,5  ]
                    },
                    {
                      "type": "Dedicated", 
                      "total": [ 5,  5 ],
                      "daily": [ 5, 5],
                      "released": [ 5,5  ]
                    }
                  ]
                }
           ]
        }
}

nested class would be better.

https://transform.tools/json-to-java