0

Is there a way to autogenerate java classes from json with jsonschema2pojo where the generics include a primitive byte array? For example i want to generate this private Map<String, byte[]> mappy; and so far I managed to generate private Map<String, Byte[]> mappy; by using this:

"properties": {
  "mappy": {
    "id": "/response/images",
    "title": "(images) The images property.",
    "javaType" : "java.util.Map<String, Byte[]>",
    "type" : "object"
  }
}

but I'd rather use the primitive byte array instead of the Byte array. If i try to use byte[] instead of Byte[] jsonschema2pojo throws an exception.

4

1 回答 1

0

OK. I figured a way by using the replacer plugin in the pom.xml file like this:

        <plugin>
            <groupId>com.google.code.maven-replacer-plugin</groupId>
            <artifactId>replacer</artifactId>
            <version>1.5.3</version>
            <executions>
                <execution>
                    <id>Convert commons-lang to commons-lang3</id>
                    <phase>generate-sources</phase>
                    <goals>
                        <goal>replace</goal>
                    </goals>
                    <configuration>
                        <includes>
                            <include>${basedir}/target/java-gen/*.java</include>
                        </includes>
                        <replacements>
                            <replacement>
                                <token>Byte</token>
                                <value>byte</value>
                            </replacement>
                        </replacements>
                    </configuration>
                </execution>
            </executions>
        </plugin>
于 2017-12-08T16:23:52.763 回答