2

I have problems with using jsonschema2pojo in my code. So, I use jsonschema2pojo generator(http://www.jsonschema2pojo.org/) to generate POJO's from this URL: http://store.steampowered.com/api/appdetails/?appids=10

Finally, I create all these class in one package 'model'. Then in I try use it to read json from link but I receive exception:

Exception in thread "main" java.lang.NullPointerException
    at controller.View.main(View.java:26)

I don't understand why. Here is code How I can do it:

public class View {
private static String urlStr = "http://store.steampowered.com/api/appdetails/?appids=10";

public static void main(String[] args) {

    ObjectMapper objectMapper = new ObjectMapper();

    try {
        Game game = objectMapper.readValue(new URL(urlStr), Game.class);

        System.out.println(game.getData().getName());
    } catch (MalformedURLException e) {
        e.printStackTrace();
    } catch (JsonParseException e) {
        e.printStackTrace();
    } catch (JsonMappingException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    }


}

}

The Game.class is finall class which I set in generator as 'Class name'.

What is wrong? How can I get all these data from this link?

In maven I configure it like that:

<plugin>
            <groupId>org.jsonschema2pojo</groupId>
            <artifactId>jsonschema2pojo-maven-plugin</artifactId>
            <version>0.4.18</version>
            <configuration>
                <sourceType>jsonschema</sourceType>
                <outputEncoding>${project.build.sourceEncoding}</outputEncoding>
                <outputDirectory>${project.build.directory}/generated-sources</outputDirectory>
                <annotationStyle>jackson2</annotationStyle>
                <generateBuilders>true</generateBuilders>
                <initializeCollections>true</initializeCollections>
            </configuration>
            <executions>
                <execution>
                    <id>generate-game</id>
                    <goals>
                        <goal>generate</goal>
                    </goals>
                    <configuration>
                        <targetPackage>model.game</targetPackage>
                        <sourceDirectory>${basedir}/src/main/resources/schema/game</sourceDirectory>
                    </configuration>
                </execution>
            </executions>
        </plugin>

As I said, all classes are in src/main/java and package 'model', my schema is in sr/main/resources/schema/ in file 'game'

And my schema looks like:

{
  "type": "object",
  "required":false,
  "javaType":"model.Game",
  "properties": {
    "10": {
      "id": "10",
      "type": "object",
      "properties": {
        "success": {
          "id": "success",
          "type": "boolean"
        },
        "data": {
          "id": "data",
          "type": "object",
          "properties": {
            "type": {
              "id": "type",
              "type": "string"
            },
            "name": {
              "id": "name",
              "type": "string"
            },
            "steam_appid": {
              "id": "steam_appid",
              "type": "integer"
            },
            "required_age": {
              "id": "required_age",
              "type": "integer"
            },
            "is_free": {
              "id": "is_free",
              "type": "boolean"
            },
            "detailed_description": {
              "id": "detailed_description",
              "type": "string"
            },
            "about_the_game": {
              "id": "about_the_game",
              "type": "string"
            },
            "supported_languages": {
              "id": "supported_languages",
              "type": "string"
            },
            "header_image": {
              "id": "header_image",
              "type": "string"
            },
            "website": {
              "id": "website",
              "type": "null"
            },
            "pc_requirements": {
              "id": "pc_requirements",
              "type": "object",
              "properties": {
                "minimum": {
                  "id": "minimum",
                  "type": "string"
                }
              }
            },
            "mac_requirements": {
              "id": "mac_requirements",
              "type": "object",
              "properties": {
                "minimum": {
                  "id": "minimum",
                  "type": "string"
                }
              }
            },
            "linux_requirements": {
              "id": "linux_requirements",
              "type": "object",
              "properties": {
                "minimum": {
                  "id": "minimum",
                  "type": "string"
                }
              }
            },
            "developers": {
              "id": "developers",
              "type": "array",
              "items": {
                "id": "0",
                "type": "string"
              }
            },
            "publishers": {
              "id": "publishers",
              "type": "array",
              "items": {
                "id": "0",
                "type": "string"
              }
            },
            "price_overview": {
              "id": "price_overview",
              "type": "object",
              "properties": {
                "currency": {
                  "id": "currency",
                  "type": "string"
                },
                "initial": {
                  "id": "initial",
                  "type": "integer"
                },
                "final": {
                  "id": "final",
                  "type": "integer"
                },
                "discount_percent": {
                  "id": "discount_percent",
                  "type": "integer"
                }
              }
            },
            "packages": {
              "id": "packages",
              "type": "array",
              "items": [
                {
                  "id": "0",
                  "type": "string"
                },
                {
                  "id": "1",
                  "type": "integer"
                },
                {
                  "id": "2",
                  "type": "integer"
                },
                {
                  "id": "3",
                  "type": "integer"
                }
              ]
            },
            "package_groups": {
              "id": "package_groups",
              "type": "array",
              "items": {
                "id": "0",
                "type": "object",
                "properties": {
                  "name": {
                    "id": "name",
                    "type": "string"
                  },
                  "title": {
                    "id": "title",
                    "type": "string"
                  },
                  "description": {
                    "id": "description",
                    "type": "string"
                  },
                  "selection_text": {
                    "id": "selection_text",
                    "type": "string"
                  },
                  "save_text": {
                    "id": "save_text",
                    "type": "string"
                  },
                  "display_type": {
                    "id": "display_type",
                    "type": "integer"
                  },
                  "is_recurring_subscription": {
                    "id": "is_recurring_subscription",
                    "type": "string"
                  },
                  "subs": {
                    "id": "subs",
                    "type": "array",
                    "items": [
                      {
                        "id": "0",
                        "type": "object",
                        "properties": {
                          "packageid": {
                            "id": "packageid",
                            "type": "string"
                          },
                          "percent_savings_text": {
                            "id": "percent_savings_text",
                            "type": "string"
                          },
                          "percent_savings": {
                            "id": "percent_savings",
                            "type": "integer"
                          },
                          "option_text": {
                            "id": "option_text",
                            "type": "string"
                          },
                          "option_description": {
                            "id": "option_description",
                            "type": "string"
                          },
                          "can_get_free_license": {
                            "id": "can_get_free_license",
                            "type": "string"
                          },
                          "is_free_license": {
                            "id": "is_free_license",
                            "type": "boolean"
                          },
                          "price_in_cents_with_discount": {
                            "id": "price_in_cents_with_discount",
                            "type": "integer"
                          }
                        }
                      },
                      {
                        "id": "1",
                        "type": "object",
                        "properties": {
                          "packageid": {
                            "id": "packageid",
                            "type": "integer"
                          },
                          "percent_savings_text": {
                            "id": "percent_savings_text",
                            "type": "string"
                          },
                          "percent_savings": {
                            "id": "percent_savings",
                            "type": "integer"
                          },
                          "option_text": {
                            "id": "option_text",
                            "type": "string"
                          },
                          "option_description": {
                            "id": "option_description",
                            "type": "string"
                          },
                          "can_get_free_license": {
                            "id": "can_get_free_license",
                            "type": "string"
                          },
                          "is_free_license": {
                            "id": "is_free_license",
                            "type": "boolean"
                          },
                          "price_in_cents_with_discount": {
                            "id": "price_in_cents_with_discount",
                            "type": "integer"
                          }
                        }
                      },
                      {
                        "id": "2",
                        "type": "object",
                        "properties": {
                          "packageid": {
                            "id": "packageid",
                            "type": "integer"
                          },
                          "percent_savings_text": {
                            "id": "percent_savings_text",
                            "type": "string"
                          },
                          "percent_savings": {
                            "id": "percent_savings",
                            "type": "integer"
                          },
                          "option_text": {
                            "id": "option_text",
                            "type": "string"
                          },
                          "option_description": {
                            "id": "option_description",
                            "type": "string"
                          },
                          "can_get_free_license": {
                            "id": "can_get_free_license",
                            "type": "string"
                          },
                          "is_free_license": {
                            "id": "is_free_license",
                            "type": "boolean"
                          },
                          "price_in_cents_with_discount": {
                            "id": "price_in_cents_with_discount",
                            "type": "integer"
                          }
                        }
                      },
                      {
                        "id": "3",
                        "type": "object",
                        "properties": {
                          "packageid": {
                            "id": "packageid",
                            "type": "integer"
                          },
                          "percent_savings_text": {
                            "id": "percent_savings_text",
                            "type": "string"
                          },
                          "percent_savings": {
                            "id": "percent_savings",
                            "type": "integer"
                          },
                          "option_text": {
                            "id": "option_text",
                            "type": "string"
                          },
                          "option_description": {
                            "id": "option_description",
                            "type": "string"
                          },
                          "can_get_free_license": {
                            "id": "can_get_free_license",
                            "type": "string"
                          },
                          "is_free_license": {
                            "id": "is_free_license",
                            "type": "boolean"
                          },
                          "price_in_cents_with_discount": {
                            "id": "price_in_cents_with_discount",
                            "type": "integer"
                          }
                        }
                      }
                    ]
                  }
                }
              }
            },
            "platforms": {
              "id": "platforms",
              "type": "object",
              "properties": {
                "windows": {
                  "id": "windows",
                  "type": "boolean"
                },
                "mac": {
                  "id": "mac",
                  "type": "boolean"
                },
                "linux": {
                  "id": "linux",
                  "type": "boolean"
                }
              }
            },
            "metacritic": {
              "id": "metacritic",
              "type": "object",
              "properties": {
                "score": {
                  "id": "score",
                  "type": "integer"
                },
                "url": {
                  "id": "url",
                  "type": "string"
                }
              }
            },
            "categories": {
              "id": "categories",
              "type": "array",
              "items": [
                {
                  "id": "0",
                  "type": "object",
                  "properties": {
                    "id": {
                      "id": "id",
                      "type": "integer"
                    },
                    "description": {
                      "id": "description",
                      "type": "string"
                    }
                  }
                },
                {
                  "id": "1",
                  "type": "object",
                  "properties": {
                    "id": {
                      "id": "id",
                      "type": "integer"
                    },
                    "description": {
                      "id": "description",
                      "type": "string"
                    }
                  }
                }
              ]
            },
            "genres": {
              "id": "genres",
              "type": "array",
              "items": {
                "id": "0",
                "type": "object",
                "properties": {
                  "id": {
                    "id": "id",
                    "type": "string"
                  },
                  "description": {
                    "id": "description",
                    "type": "string"
                  }
                }
              }
            },
            "screenshots": {
              "id": "screenshots",
              "type": "array",
              "items": [
                {
                  "id": "0",
                  "type": "object",
                  "properties": {
                    "id": {
                      "id": "id",
                      "type": "integer"
                    },
                    "path_thumbnail": {
                      "id": "path_thumbnail",
                      "type": "string"
                    },
                    "path_full": {
                      "id": "path_full",
                      "type": "string"
                    }
                  }
                },
                {
                  "id": "1",
                  "type": "object",
                  "properties": {
                    "id": {
                      "id": "id",
                      "type": "integer"
                    },
                    "path_thumbnail": {
                      "id": "path_thumbnail",
                      "type": "string"
                    },
                    "path_full": {
                      "id": "path_full",
                      "type": "string"
                    }
                  }
                },
                {
                  "id": "2",
                  "type": "object",
                  "properties": {
                    "id": {
                      "id": "id",
                      "type": "integer"
                    },
                    "path_thumbnail": {
                      "id": "path_thumbnail",
                      "type": "string"
                    },
                    "path_full": {
                      "id": "path_full",
                      "type": "string"
                    }
                  }
                },
                {
                  "id": "3",
                  "type": "object",
                  "properties": {
                    "id": {
                      "id": "id",
                      "type": "integer"
                    },
                    "path_thumbnail": {
                      "id": "path_thumbnail",
                      "type": "string"
                    },
                    "path_full": {
                      "id": "path_full",
                      "type": "string"
                    }
                  }
                },
                {
                  "id": "4",
                  "type": "object",
                  "properties": {
                    "id": {
                      "id": "id",
                      "type": "integer"
                    },
                    "path_thumbnail": {
                      "id": "path_thumbnail",
                      "type": "string"
                    },
                    "path_full": {
                      "id": "path_full",
                      "type": "string"
                    }
                  }
                },
                {
                  "id": "5",
                  "type": "object",
                  "properties": {
                    "id": {
                      "id": "id",
                      "type": "integer"
                    },
                    "path_thumbnail": {
                      "id": "path_thumbnail",
                      "type": "string"
                    },
                    "path_full": {
                      "id": "path_full",
                      "type": "string"
                    }
                  }
                },
                {
                  "id": "6",
                  "type": "object",
                  "properties": {
                    "id": {
                      "id": "id",
                      "type": "integer"
                    },
                    "path_thumbnail": {
                      "id": "path_thumbnail",
                      "type": "string"
                    },
                    "path_full": {
                      "id": "path_full",
                      "type": "string"
                    }
                  }
                },
                {
                  "id": "7",
                  "type": "object",
                  "properties": {
                    "id": {
                      "id": "id",
                      "type": "integer"
                    },
                    "path_thumbnail": {
                      "id": "path_thumbnail",
                      "type": "string"
                    },
                    "path_full": {
                      "id": "path_full",
                      "type": "string"
                    }
                  }
                },
                {
                  "id": "8",
                  "type": "object",
                  "properties": {
                    "id": {
                      "id": "id",
                      "type": "integer"
                    },
                    "path_thumbnail": {
                      "id": "path_thumbnail",
                      "type": "string"
                    },
                    "path_full": {
                      "id": "path_full",
                      "type": "string"
                    }
                  }
                },
                {
                  "id": "9",
                  "type": "object",
                  "properties": {
                    "id": {
                      "id": "id",
                      "type": "integer"
                    },
                    "path_thumbnail": {
                      "id": "path_thumbnail",
                      "type": "string"
                    },
                    "path_full": {
                      "id": "path_full",
                      "type": "string"
                    }
                  }
                },
                {
                  "id": "10",
                  "type": "object",
                  "properties": {
                    "id": {
                      "id": "id",
                      "type": "integer"
                    },
                    "path_thumbnail": {
                      "id": "path_thumbnail",
                      "type": "string"
                    },
                    "path_full": {
                      "id": "path_full",
                      "type": "string"
                    }
                  }
                },
                {
                  "id": "11",
                  "type": "object",
                  "properties": {
                    "id": {
                      "id": "id",
                      "type": "integer"
                    },
                    "path_thumbnail": {
                      "id": "path_thumbnail",
                      "type": "string"
                    },
                    "path_full": {
                      "id": "path_full",
                      "type": "string"
                    }
                  }
                },
                {
                  "id": "12",
                  "type": "object",
                  "properties": {
                    "id": {
                      "id": "id",
                      "type": "integer"
                    },
                    "path_thumbnail": {
                      "id": "path_thumbnail",
                      "type": "string"
                    },
                    "path_full": {
                      "id": "path_full",
                      "type": "string"
                    }
                  }
                }
              ]
            },
            "recommendations": {
              "id": "recommendations",
              "type": "object",
              "properties": {
                "total": {
                  "id": "total",
                  "type": "integer"
                }
              }
            },
            "achievements": {
              "id": "achievements",
              "type": "object",
              "properties": {
                "total": {
                  "id": "total",
                  "type": "integer"
                }
              }
            },
            "release_date": {
              "id": "release_date",
              "type": "object",
              "properties": {
                "coming_soon": {
                  "id": "coming_soon",
                  "type": "boolean"
                },
                "date": {
                  "id": "date",
                  "type": "string"
                }
              }
            },
            "support_info": {
              "id": "support_info",
              "type": "object",
              "properties": {
                "url": {
                  "id": "url",
                  "type": "string"
                },
                "email": {
                  "id": "email",
                  "type": "string"
                }
              }
            },
            "background": {
              "id": "background",
              "type": "string"
            }
          }
        }
      },
      "required": [
        "success",
        "data",
        "id",
        "path_thumbnail",
        "path_full"
      ]
    }
  },
  "required": [
    "10"
  ]
}

With this config I can read all data using this line instead of before System.out.println:

System.out.println( objectMapper.writeValueAsString( game ) );

Now I can see full json string, but how can I read it using 'game.getData().getName()' etc ?

ullQuiorra
  • 31
  • 1
  • 6

2 Answers2

0

The JSON schema that you gave defines "10" as a top-level property containing everything else.

{
  "type": "object",
  "required":false,
  "javaType":"model.Game",
  "properties": {
    "10": {
      "id": "10",
      "type": "object",
      "properties": {
        "success": {
          "id": "success",
          "type": "boolean"
        },
        "data": {
          "id": "data",
          "type": "object",
          "properties": {
            "type": {
              "id": "type",
              "type": "string"
            },
            "name": {
              "id": "name",
              "type": "string"
            },
...

jsonschema2pojo reads that schema and generates a class named _10 as part of the model. You can find this in _10.java in the generated-sources directory.

@JsonInclude(JsonInclude.Include.NON_NULL)
@Generated("org.jsonschema2pojo")
@JsonPropertyOrder({
    "success",
    "data"
})
public class _10 {

I don't know if this was intentional in the schema. If it's intentional, then you would need to access the name like this.

System.out.println(game.get10().getData().getName());

I was able to get it working after making that change.

EDIT: It appears these JSON messages are expected to have a variable ID as a top-level key containing everything else, so we need to handle this a bit differently. We can generalize the schema so that it isn't specific to a particular ID, and then we can use a two-step process to parse the message. First, we'll use [ObjectMapper#readValue](https://fasterxml.github.io/jackson-databind/javadoc/2.5/com/fasterxml/jackson/databind/ObjectMapper.html#readValue(java.net.URL, com.fasterxml.jackson.core.type.TypeReference)) to parse the whole message into a Map<String, Object>. We expect that top-level map will contain a single element, corresponding to the ID of the document we requested, and its value will be a sub-map containing the values we're interested in. We'll then pass that sub-map through [ObjectMapper#convertValue](https://fasterxml.github.io/jackson-databind/javadoc/2.5/com/fasterxml/jackson/databind/ObjectMapper.html#convertValue(java.lang.Object, java.lang.Class)) to get the Game object that we want.

pom.xml

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>cnauroth</groupId>
    <artifactId>test-json</artifactId>
    <packaging>jar</packaging>
    <version>0.0.1-SNAPSHOT</version>
    <name>Test JSON</name>
    <description>Test JSON</description>
    <build>
        <plugins>            
            <plugin>
                <groupId>org.jsonschema2pojo</groupId>
                <artifactId>jsonschema2pojo-maven-plugin</artifactId>
                <version>0.4.18</version>
                <configuration>
                    <sourceType>jsonschema</sourceType>
                    <outputEncoding>${project.build.sourceEncoding}</outputEncoding>
                    <outputDirectory>${project.build.directory}/generated-sources/java</outputDirectory>
                    <annotationStyle>jackson2</annotationStyle>
                    <generateBuilders>true</generateBuilders>
                    <initializeCollections>true</initializeCollections>
                </configuration>
                <executions>
                    <execution>
                        <id>generate-game</id>
                        <goals>
                            <goal>generate</goal>
                        </goals>
                        <configuration>
                            <targetPackage>model.game</targetPackage>
                            <sourceDirectory>${basedir}/src/main/resources/schema/game</sourceDirectory>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <artifactId>maven-assembly-plugin</artifactId>
                <configuration>
                    <archive>
                        <manifest>
                            <addDefaultImplementationEntries>true</addDefaultImplementationEntries>
                            <mainClass>View</mainClass>
                        </manifest>
                    </archive>
                    <descriptorRefs>
                        <descriptorRef>jar-with-dependencies</descriptorRef>
                    </descriptorRefs>
                    <finalName>${project.artifactId}</finalName>
                    <appendAssemblyId>false</appendAssemblyId>
                </configuration>
                <executions>
                    <execution>
                        <id>make-assembly</id>
                        <phase>package</phase>
                        <goals>
                            <goal>single</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
    <dependencies>
        <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-databind</artifactId>
            <version>2.5.0</version>
        </dependency>
        <dependency>
            <groupId>commons-lang</groupId>
            <artifactId>commons-lang</artifactId>
            <version>2.6</version>
        </dependency>
    </dependencies>
</project>

game

The JSON schema file is too large to paste, so here is a link to a gist.

View.java

import java.net.URI;
import java.util.Map;

import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;

import model.Game;

public class View {

    public static void main(String[] args) throws Exception {
        String id = args[0];
        URI uri = new URI("http", "store.steampowered.com", "/api/appdetails",
                "appids=" + id, null);
        ObjectMapper objectMapper = new ObjectMapper();
        Map<String, Object> obj = objectMapper.readValue(uri.toURL(),
                new TypeReference<Map<String, Object>>(){});
        Game game = objectMapper.convertValue(obj.get(id), Game.class);
        System.out.println(game.getData().getName());
    }
}

Demo

> mvn clean package

> java -jar target/test-json.jar 10
Counter-Strike

> java -jar target/test-json.jar 219
Half-Life 2: Demo

Additionally, I needed to make one other change to the schema. I removed the linux_requirements property. This is because looking at document 10 vs. document 219, it's an object in the former and it's an array in the latter. For document 219, the parser didn't know how to make sense of the array, because we were expecting an object. It's odd for data returned from an API to be inconsistent like this. You might need to do some more tinkering with the schema to get this fully working for all possible JSON documents returned from that API.

I have put all of the code into a GitHub repository. You can take that code, build it and run it to see it working. Then, you can adapt it further to your needs.

Chris Nauroth
  • 9,614
  • 1
  • 35
  • 39
  • But did you try use other ID in URL if this clas _10 works for id=219 too ? – ullQuiorra Dec 31 '15 at 00:44
  • I tried to do that like you but I got exception: Unrecognized field "steam_appid" (Class model.Data), not marked as ignorable – ullQuiorra Dec 31 '15 at 00:49
  • If the ID (which is variable) is expected as a key in the format, then you might consider doing a two-step process of parsing the whole thing to a raw Map without specific data binding, then pull out the sub-map corresponding to the key, and round-trip that sub-map by serializing back to JSON and deserializing again using the generic schema, which doesn't specify "10" or any other specific ID. – Chris Nauroth Dec 31 '15 at 00:51
  • Unfortunately I don't know how I can do that. – ullQuiorra Dec 31 '15 at 01:01
  • @ullQuiorra, understood. :-) I just edited my answer to show a code sample for this two-step parsing process I was proposing. I hope this helps. – Chris Nauroth Dec 31 '15 at 03:22
  • unfortunatelly doesn't works, still null pointer exception :( – ullQuiorra Dec 31 '15 at 14:23
  • @ullQuiorra, are you running the exact same code I gave? See the Demo section above that shows a working test run with no `NullPointerException`. – Chris Nauroth Dec 31 '15 at 16:21
  • @ullQuiorra, I also added a link to a GitHub gist containing my version of the schema. Make sure you're using that version of the schema. https://gist.github.com/cnauroth/f492fbd008dba13cf069 – Chris Nauroth Dec 31 '15 at 16:27
  • Yes I use exactly the same code but I used different schema. Now I tried use your json schema but still the same NullPointerException – ullQuiorra Dec 31 '15 at 16:44
  • @ullQuiorra, I just edited the answer again to provide a link to a [GitHub repository](https://github.com/cnauroth/jsonschema2pojo-test) with the full code. Please take that, build it and run it to see it working. I hope this helps. – Chris Nauroth Dec 31 '15 at 21:58
  • Unfortunately doesn't help too. I found library which does exactly the same what I wanted so I use it now. I have no time to trying resolve this problem but really thanks for your help :) – ullQuiorra Jan 04 '16 at 13:57
  • @ullQuiorra, it's odd that the code that worked on my end didn't work for you. Anyway, I'm glad to help, and glad to hear you solved it. :-) If you want, consider adding a comment with a link to that library that helped you, or enter your own answer and self-accept it. That might help others who find this question later. – Chris Nauroth Jan 04 '16 at 18:02
  • 1
    You'r right, here is link to this library: https://github.com/go-ive/steam-api :) – ullQuiorra Jan 04 '16 at 18:28
0

Instead of trying to model the object containing the ids with properties, use additionalProperties. Assuming that the top level type contains several games, you could try replacing

{
  "type": "object",
  "required":false,
  "javaType":"model.Game",
  "properties": {
    "10": {
      "id": "10",
      "type": "object",
      ...
    }
  }
}

with something like

{
  "type": "object",
  "required":false,
  "javaType":"model.Games",
  "additionalProperties": {
      "id": "game",
      "type": "object",
      "javaType": "model.Game"
      ...
  }
}

This should make a model.Games type with a method like public Map<String, Game> getAdditionalProperties().

Christian Trimble
  • 2,126
  • 16
  • 27