fasterxml / jackson-datatype-json-org Goto Github PK
View Code? Open in Web Editor NEW(DEPRECATED) Support for org.json data types, to ease migration out of code that uses them
(DEPRECATED) Support for org.json data types, to ease migration out of code that uses them
Only 2.10.0.pr3
is available from maven central. Other Jackson 2.10.0
artifacts are available and https://github.com/FasterXML/jackson/wiki/Jackson-Release-2.10 states that Jackson 2.10 was released today.
When attempting to serialize a JSONObject with a null value the following exception is thrown:
java.util.NoSuchElementException: JSONObject["xxxx"] not found.
at org.json.JSONObject.get(JSONObject.java:220)
at com.fasterxml.jackson.datatype.jsonorg.JSONObjectSerializer.serializeContents(JSONObjectSerializer.java:57)
at com.fasterxml.jackson.datatype.jsonorg.JSONObjectSerializer.serialize(JSONObjectSerializer.java:28)
at com.fasterxml.jackson.datatype.jsonorg.JSONObjectSerializer.serialize(JSONObjectSerializer.java:14)
It seems like the following code in JSONObjectSerializer
try {
ob = value.get(key);
} catch (JSONException e) {
throw new JsonGenerationException(e);
}
if (ob == null || ob == JSONObject.NULL) {
if (provider.isEnabled(SerializationConfig.Feature.WRITE_NULL_MAP_VALUES)) {
jgen.writeNullField(key);
}
continue;
}
should instead be:
try {
ob = value.opt(key);
} catch (JSONException e) {
throw new JsonGenerationException(e);
}
if (ob == null || ob == JSONObject.NULL) {
if (provider.isEnabled(SerializationConfig.Feature.WRITE_NULL_MAP_VALUES)) {
jgen.writeNullField(key);
}
continue;
}
Great little library but without a License it is rather useless. Would it be possible to add a License file?
Thanks,
Tim
public class TestDomain {
private Integer id;
private String name;
private Double da;
private LocalDateTime ldt;
private LocalDate ld;
private LocalTime lt;
private JSONObject jsn;
private JSONArray jsa;
}
execute code
public static void main(String[] args) {
Map map = new HashMap();
map.put("name", "zpj");
map.put("id", 111);
map.put("jsa", "[1, 34, 32, \"zpj\", {\"age\": 18, \"name\": \"zpj\", \"child\": {\"name\": \"zzy\", \"gender\": \"nan\"}}, {\"url\": \"test\", \"name\": \"suhu\"}]");
ObjectMapper om = new ObjectMapper();
om.registerModule(new JsonOrgModule());
TestDomain td = om.convertValue(map, TestDomain.class);
System.out.println(td);
}
Exception in thread "main" java.lang.IllegalArgumentException: Can not deserialize instance of org.json.JSONArray out of FIELD_NAME token
throws java.lang.IllegalArgumentException: Can not deserialize instance of org.json.JSONArray out of
It would make sense to be able to prune empty
(and default value) output when serializing.
(note: cleaved from #7)
It would be nice to support this SerializationFeature
, along with other options to filter out "empty" items of various types.
This is the part of FasterXML/jackson-databind#2434 that relates to changes to the jackson-datatype-json-org project.
I get this is the wrong place. But I could not find the home for geronimo bundles. Is far as I can tell is is dead.
However in my attempts to modularize my quandl library which depends on com.jimmoores:quandl-core which in turn depends on this somehow, I discovered that the automatic module naming algorithm fails to name the json-2090211_1 with a valid module name.
I have found that if the line 'Automatic-Module-Name: org.json' is added to the MANIFEST.MF in the META-INF within the json-20090211_1.jar then my library compiles.
FYI...
I think the OSGi ready dependency would be more appropriate selection for this library. Please consider to change the dependency for example to this:
<dependency>
<groupId>org.apache.geronimo.bundles</groupId>
<artifactId>json</artifactId>
<version>20090211_1</version>
</dependency>
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.