JSON standards - and polymorphism2019 Community Moderator ElectionHow do I format a Microsoft JSON date?Can comments be used in JSON?How can I pretty-print JSON in a shell script?What is the correct JSON content type?Why does Google prepend while(1); to their JSON responses?Parsing values from a JSON file?How can I pretty-print JSON using JavaScript?Parse JSON in JavaScript?How to POST JSON data with Curl from Terminal/Commandline to Test Spring REST?JsonMappingException: No suitable constructor found for type [simple type, class ]: can not instantiate from JSON object
What options are left, if Britain cannot decide?
When do we add an hyphen (-) to a complex adjective word?
How do I hide Chekhov's Gun?
Is it possible to upcast ritual spells?
At what level can a dragon innately cast its spells?
Employee lack of ownership
Why does Deadpool say "You're welcome, Canada," after shooting Ryan Reynolds in the end credits?
Co-worker team leader wants to inject his friend's awful software into our development. What should I say to our common boss?
Why did it take so long to abandon sail after steamships were demonstrated?
How to explain that I do not want to visit a country due to personal safety concern?
What are some nice/clever ways to introduce the tonic's dominant seventh chord?
Current sense amp + op-amp buffer + ADC: Measuring down to 0 with single supply
How could a female member of a species produce eggs unto death?
Good allowance savings plan?
Calculus II Professor will not accept my correct integral evaluation that uses a different method, should I bring this up further?
Is having access to past exams cheating and, if yes, could it be proven just by a good grade?
Does splitting a potentially monolithic application into several smaller ones help prevent bugs?
How to write cleanly even if my character uses expletive language?
An Accountant Seeks the Help of a Mathematician
Meaning of "SEVERA INDEOVI VAS" from 3rd Century slab
What is the greatest age difference between a married couple in Tanach?
How to deal with taxi scam when on vacation?
Make a transparent 448*448 image
Where is the 1/8 CR apprentice in Volo's Guide to Monsters?
JSON standards - and polymorphism
2019 Community Moderator ElectionHow do I format a Microsoft JSON date?Can comments be used in JSON?How can I pretty-print JSON in a shell script?What is the correct JSON content type?Why does Google prepend while(1); to their JSON responses?Parsing values from a JSON file?How can I pretty-print JSON using JavaScript?Parse JSON in JavaScript?How to POST JSON data with Curl from Terminal/Commandline to Test Spring REST?JsonMappingException: No suitable constructor found for type [simple type, class ]: can not instantiate from JSON object
We are primarily Java
shop with Spring
/Hibernate
etc. We have REST
based API
that is consumed by our customers who may or may not be using Java
.
One of the problems our customers face is converting object to concrete type because of polymorphism.
If all our customers were using Java/Spring
, I can tinker settings of object mapper to return information about types. One such example can be found at baeldung and polymorphism
I'm not clear if type information embedded generated JSON
is considered as valid JSON
by other JSON
parsers say in Python
/Node
-Javascript
/.NET
etc and whether it will break their code.
Are there any standards when it comes to type information embedded in JSON
like Jackson
does it. Google search did not reveal much.
python .net json jackson polymorphism
add a comment |
We are primarily Java
shop with Spring
/Hibernate
etc. We have REST
based API
that is consumed by our customers who may or may not be using Java
.
One of the problems our customers face is converting object to concrete type because of polymorphism.
If all our customers were using Java/Spring
, I can tinker settings of object mapper to return information about types. One such example can be found at baeldung and polymorphism
I'm not clear if type information embedded generated JSON
is considered as valid JSON
by other JSON
parsers say in Python
/Node
-Javascript
/.NET
etc and whether it will break their code.
Are there any standards when it comes to type information embedded in JSON
like Jackson
does it. Google search did not reveal much.
python .net json jackson polymorphism
add a comment |
We are primarily Java
shop with Spring
/Hibernate
etc. We have REST
based API
that is consumed by our customers who may or may not be using Java
.
One of the problems our customers face is converting object to concrete type because of polymorphism.
If all our customers were using Java/Spring
, I can tinker settings of object mapper to return information about types. One such example can be found at baeldung and polymorphism
I'm not clear if type information embedded generated JSON
is considered as valid JSON
by other JSON
parsers say in Python
/Node
-Javascript
/.NET
etc and whether it will break their code.
Are there any standards when it comes to type information embedded in JSON
like Jackson
does it. Google search did not reveal much.
python .net json jackson polymorphism
We are primarily Java
shop with Spring
/Hibernate
etc. We have REST
based API
that is consumed by our customers who may or may not be using Java
.
One of the problems our customers face is converting object to concrete type because of polymorphism.
If all our customers were using Java/Spring
, I can tinker settings of object mapper to return information about types. One such example can be found at baeldung and polymorphism
I'm not clear if type information embedded generated JSON
is considered as valid JSON
by other JSON
parsers say in Python
/Node
-Javascript
/.NET
etc and whether it will break their code.
Are there any standards when it comes to type information embedded in JSON
like Jackson
does it. Google search did not reveal much.
python .net json jackson polymorphism
python .net json jackson polymorphism
edited Mar 6 at 19:22
Michał Ziober
15.7k1168106
15.7k1168106
asked Mar 6 at 18:52
user871199user871199
8281022
8281022
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
There is no one standard which all frameworks must follow. Even Jackson
can do that on many different ways whatever user decide to use. Also Jackson
always generate valid JSON
even when whole class name is used such as "org.baeldung.jackson.inheritance.Car"
or "org.baeldung.jackson.inheritance.Truck"
. To make it work and easy to use you must clarify all base types
and subtypes
in:
- documentation
JSon Schema
There is no point to send whole class
name because non Java
clients will not recognise them automatically anyway. So, you need to create mapping:
BP
- base productP1
- product 1P2
- product 2- ...
You also mast to specify, that for example, each object contains "type"
property which will be set to one from above list:
[
"type":"P1",
"model":"S500",
"cost":250.0
,
"type":"P2",
"model":"NQR",
"capacity":7500.0
]
Above should provide enough information to deserialise
any payload
.
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55030265%2fjson-standards-and-polymorphism%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
There is no one standard which all frameworks must follow. Even Jackson
can do that on many different ways whatever user decide to use. Also Jackson
always generate valid JSON
even when whole class name is used such as "org.baeldung.jackson.inheritance.Car"
or "org.baeldung.jackson.inheritance.Truck"
. To make it work and easy to use you must clarify all base types
and subtypes
in:
- documentation
JSon Schema
There is no point to send whole class
name because non Java
clients will not recognise them automatically anyway. So, you need to create mapping:
BP
- base productP1
- product 1P2
- product 2- ...
You also mast to specify, that for example, each object contains "type"
property which will be set to one from above list:
[
"type":"P1",
"model":"S500",
"cost":250.0
,
"type":"P2",
"model":"NQR",
"capacity":7500.0
]
Above should provide enough information to deserialise
any payload
.
add a comment |
There is no one standard which all frameworks must follow. Even Jackson
can do that on many different ways whatever user decide to use. Also Jackson
always generate valid JSON
even when whole class name is used such as "org.baeldung.jackson.inheritance.Car"
or "org.baeldung.jackson.inheritance.Truck"
. To make it work and easy to use you must clarify all base types
and subtypes
in:
- documentation
JSon Schema
There is no point to send whole class
name because non Java
clients will not recognise them automatically anyway. So, you need to create mapping:
BP
- base productP1
- product 1P2
- product 2- ...
You also mast to specify, that for example, each object contains "type"
property which will be set to one from above list:
[
"type":"P1",
"model":"S500",
"cost":250.0
,
"type":"P2",
"model":"NQR",
"capacity":7500.0
]
Above should provide enough information to deserialise
any payload
.
add a comment |
There is no one standard which all frameworks must follow. Even Jackson
can do that on many different ways whatever user decide to use. Also Jackson
always generate valid JSON
even when whole class name is used such as "org.baeldung.jackson.inheritance.Car"
or "org.baeldung.jackson.inheritance.Truck"
. To make it work and easy to use you must clarify all base types
and subtypes
in:
- documentation
JSon Schema
There is no point to send whole class
name because non Java
clients will not recognise them automatically anyway. So, you need to create mapping:
BP
- base productP1
- product 1P2
- product 2- ...
You also mast to specify, that for example, each object contains "type"
property which will be set to one from above list:
[
"type":"P1",
"model":"S500",
"cost":250.0
,
"type":"P2",
"model":"NQR",
"capacity":7500.0
]
Above should provide enough information to deserialise
any payload
.
There is no one standard which all frameworks must follow. Even Jackson
can do that on many different ways whatever user decide to use. Also Jackson
always generate valid JSON
even when whole class name is used such as "org.baeldung.jackson.inheritance.Car"
or "org.baeldung.jackson.inheritance.Truck"
. To make it work and easy to use you must clarify all base types
and subtypes
in:
- documentation
JSon Schema
There is no point to send whole class
name because non Java
clients will not recognise them automatically anyway. So, you need to create mapping:
BP
- base productP1
- product 1P2
- product 2- ...
You also mast to specify, that for example, each object contains "type"
property which will be set to one from above list:
[
"type":"P1",
"model":"S500",
"cost":250.0
,
"type":"P2",
"model":"NQR",
"capacity":7500.0
]
Above should provide enough information to deserialise
any payload
.
answered Mar 6 at 19:35
Michał ZioberMichał Ziober
15.7k1168106
15.7k1168106
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55030265%2fjson-standards-and-polymorphism%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown