Last active
May 23, 2017 22:10
-
-
Save Nava2/c166524b17a51a617da90263d53924f0 to your computer and use it in GitHub Desktop.
Simple examples used in FasterXML/jackson-modules-java8#1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Bar { | |
public String name; | |
public Bar(@JsonProperty("name") String name) { | |
this.name = name; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Foo { | |
private final ObjectProperty<Bar> bar; | |
@JsonCreator | |
public Foo(@JsonProperty("bar") Bar bar) { | |
this.bar = new SimpleObjectProperty<>(this, "bar", bar); | |
} | |
public Bar getBar() { | |
return bar.get(); | |
} | |
public ObjectProperty<Bar> barProperty() { | |
return bar; | |
} | |
public void setBar(Bar bar) { | |
this.bar.set(bar); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[ | |
{ | |
"bar" : { | |
"@id" : 1, | |
"name" : "bar", | |
"value" : { | |
"name" : "bar" | |
} | |
} | |
}, { | |
"bar" : { | |
"@id" : 2, | |
"name" : "bar", | |
"bound" : true, | |
"value" : 1 | |
} | |
} | |
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Foo f1 = new Foo(null); | |
Foo f2 = new Foo(null); | |
Bar bar = new Bar("bar"); | |
f1.barProperty().setValue(bar); | |
f2.barProperty().bind(f1.barProperty()); | |
ObjectMapper mapper = new ObjectMapper(); | |
mapper.registerModule(new JavaFXModule()); | |
String json = mapper.writerWithDefaultPrettyPrinter().writeValueAsString(Arrays.asList(f1, f2)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment