Generate POJO classes to a single class instead of many classes

83 views
Skip to first unread message

GOKUL ANANTH NKP

unread,
Mar 12, 2018, 5:08:52 AM3/12/18
to jsonschema2pojo-users
Hi,
Is it possible to generate a single java class instead of many classes?
For example:If i create POJO classes for the given JSON data,2 classes are created
{
    "name":"John",
    "age":30,
    "cars": [    
        { "name":"BMW", "models":[ "320", "X3", "X5" ] },
        { "name":"Fiat", "models":[ "500", "Panda" ] },
         { "name":"Ford", "models":[ "Fiesta", "Focus", "Mustang" ] }
    ]
 }

One for name,age,car and another one for car's name and model.
Instead of 2 classes being created,is it possible to generate all classes in a single java class.
Thanks in advance.

Joe Littlejohn

unread,
Mar 12, 2018, 6:49:24 AM3/12/18
to jsonschema...@googlegroups.com
Hi

Do you mean create static inner classes?
 
No, I'm afraid there's no way to force all classes into a single outer class.

GOKUL ANANTH NKP

unread,
Mar 13, 2018, 12:09:27 AM3/13/18
to jsonschema2pojo-users
Hi Joe,
 
    Thanks for your quick reply.

Is there any alternate for that or can you give any suggestion for that case.

Joe Littlejohn

unread,
Mar 13, 2018, 9:56:51 AM3/13/18
to jsonschema...@googlegroups.com
Could you explain why you need this? Maybe there is an alternative that does not involve creating everything in one class.

--
You received this message because you are subscribed to the Google Groups "jsonschema2pojo-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jsonschema2pojo-users+unsub...@googlegroups.com.
Visit this group at https://groups.google.com/group/jsonschema2pojo-users.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages