Tuesday, October 7, 2014

Json very nice tool

Given by Greg

Very nice tool !

http://www.jsonschema2pojo.org/

Enable to visualize how will look the generated java POJO code by giving its json schema representation.

For ex:

Assuming the following  Json schema:

{
  "type":"object",
  "properties": {
    "foo": {
      "type": "string"
    },
    "bar": {
      "type": "integer"
    },
    "baz": {
      "type": "boolean"
    }
  }
}

You'll obtain the following JAVA POJO class:
-----------------------------------com.example.Example.java-----------------------------------

package com.example;

import java.util.HashMap;
import java.util.Map;
import javax.annotation.Generated;
import com.fasterxml.jackson.annotation.JsonAnyGetter;
import com.fasterxml.jackson.annotation.JsonAnySetter;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonPropertyOrder;

@JsonInclude(JsonInclude.Include.NON_NULL)
@Generated("org.jsonschema2pojo")
@JsonPropertyOrder({
"foo",
"bar",
"baz"
})
public class Example {

@JsonProperty("foo")
private String foo;
@JsonProperty("bar")
private Integer bar;
@JsonProperty("baz")
private Boolean baz;
@JsonIgnore
private Map<StringObject> additionalProperties = new HashMap<StringObject>();

@JsonProperty("foo")
public String getFoo() {
return foo;
}

@JsonProperty("foo")
public void setFoo(String foo) {
this.foo = foo;
}

@JsonProperty("bar")
public Integer getBar() {
return bar;
}

@JsonProperty("bar")
public void setBar(Integer bar) {
this.bar = bar;
}

@JsonProperty("baz")
public Boolean getBaz() {
return baz;
}

@JsonProperty("baz")
public void setBaz(Boolean baz) {
this.baz = baz;
}

@JsonAnyGetter
public Map<StringObject> getAdditionalProperties() {
return this.additionalProperties;
}

@JsonAnySetter
public void setAdditionalProperty(String nameObject value) {
this.additionalProperties.put(namevalue);
}

}

No comments: