FasterXML / FasterXML/jackson-databind

Add mechanism, annotation, to handle "JSON-in-JSON" case

Open
#1,375 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
3.7k
Forks
1.5k
Avg merge
3d 6h
Merged PRs (30d)
28

Description

One common (anti?-)pattern that exists is for a JSON-String valued property to contain JSON-encoded value; effectively using double-encoding. It would be nice to be able to support such case automatically with just an annotation, like `@JsonDoubleEncoded` or something.
What this would do would be allow usage like:

``` java
public class Funny {
public int id;
@JsonDoubleEncoded
public Map attrs;
```

but produce something where `attrs` is actually JSON String, and not JSON Object; encoded further as JSON.

For extra points this should also work for other data-formats; but most likely would have to be limited to "in-kind" encoding as there isn't a good way to access other backends at the point where this is needed. For trans-coding (like JSON in XML, XML in JSON, JSON in Protobuf, whatever) custom handler would still be needed.
Note: although technically, at this point, producing JSON can actually be done from all other data-formats (due to original being JSON-centric), I don't think we should rely on this since going forward this invariant might not hold, and we want to lessen, not strengthen this dependency.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.