question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Cannot generate a complex type for lists.

See original GitHub issue

Hi,

I was trying to generate java classes for the following json schema.

{
  "type":"object",
  "properties": {
      "container": {
          "items": [
            {
              "item1": {
                "type": "string"
              }
            },
            {
              "item2": {
                "type": "string"
              }
            }
            ],
        "type":"array"
          }
  }
}

It seems jsonschema2pojo cannot generate a type for list. In java classes the list container has the type Object .

java private List<Object> container = new ArrayList<Object>();

However i would expect something like this.

private List<Container> container = new ArrayList<Object>();

And the corresponding container class.

class Container {
     private String item1; 
     private String item2; 
    // getters and setters 
    .... 
}

Is it a bug or is there some parameter to be specified to do this?

Regards, Shamsi

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
shmsicommented, Jul 17, 2018

The example seems like perfectly fine schema. You can find similar ones here

UPDATE Never mind. That is actually wrong. The flaw is in generated json files. You can close this issue

Thanks!

0reactions
joelittlejohncommented, Jul 17, 2018

What is the thing inside the array? Is it an object with a property called item1? That schema would look like this:

{
  "type":"object",
  "properties":{
    "item1": {
      "type": "string"
    }
  }
}

Show me where, in the link you provided, there is an example that looks like yours.

Read more comments on GitHub >

github_iconTop Results From Across the Web

cannot generate classes because no top-level elements with ...
I am trying to create a class from a xsd file using the XSD.EXE tool. but for some reason i get this error....
Read more >
XML Schema complexType Element - W3Schools
True indicates that an element cannot use this complex type directly but must use a complex type derived from this complex type. Default...
Read more >
Querying arrays with complex types and nested structures
Your source data often contains arrays with complex data types and nested structures. Examples in this section show how to change element's data...
Read more >
Supported XSD Elements and JPA Annotations - Appian 22.2
Anonymous lists are treated as anonymous simple data types that cannot be selected when creating new variables, rules, constants, and entities. When importing...
Read more >
Tutorial: Create a more complex data model for an ASP.NET ...
In this tutorial you'll add more entities and relationships and you'll customize the data model by specifying formatting, validation, ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found