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










0















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.










share|improve this question




























    0















    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.










    share|improve this question


























      0












      0








      0








      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.










      share|improve this question
















      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






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Mar 6 at 19:22









      Michał Ziober

      15.7k1168106




      15.7k1168106










      asked Mar 6 at 18:52









      user871199user871199

      8281022




      8281022






















          1 Answer
          1






          active

          oldest

          votes


















          2














          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 product


          • P1 - product 1


          • P2 - 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.






          share|improve this answer






















            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
            );



            );













            draft saved

            draft discarded


















            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









            2














            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 product


            • P1 - product 1


            • P2 - 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.






            share|improve this answer



























              2














              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 product


              • P1 - product 1


              • P2 - 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.






              share|improve this answer

























                2












                2








                2







                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 product


                • P1 - product 1


                • P2 - 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.






                share|improve this answer













                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 product


                • P1 - product 1


                • P2 - 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.







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Mar 6 at 19:35









                Michał ZioberMichał Ziober

                15.7k1168106




                15.7k1168106





























                    draft saved

                    draft discarded
















































                    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.




                    draft saved


                    draft discarded














                    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





















































                    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







                    Popular posts from this blog

                    Save data to MySQL database using ExtJS and PHP [closed]2019 Community Moderator ElectionHow can I prevent SQL injection in PHP?Which MySQL data type to use for storing boolean valuesPHP: Delete an element from an arrayHow do I connect to a MySQL Database in Python?Should I use the datetime or timestamp data type in MySQL?How to get a list of MySQL user accountsHow Do You Parse and Process HTML/XML in PHP?Reference — What does this symbol mean in PHP?How does PHP 'foreach' actually work?Why shouldn't I use mysql_* functions in PHP?

                    Compiling GNU Global with universal-ctags support Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern) Data science time! April 2019 and salary with experience The Ask Question Wizard is Live!Tags for Emacs: Relationship between etags, ebrowse, cscope, GNU Global and exuberant ctagsVim and Ctags tips and trickscscope or ctags why choose one over the other?scons and ctagsctags cannot open option file “.ctags”Adding tag scopes in universal-ctagsShould I use Universal-ctags?Universal ctags on WindowsHow do I install GNU Global with universal ctags support using Homebrew?Universal ctags with emacsHow to highlight ctags generated by Universal Ctags in Vim?

                    Add ONERROR event to image from jsp tldHow to add an image to a JPanel?Saving image from PHP URLHTML img scalingCheck if an image is loaded (no errors) with jQueryHow to force an <img> to take up width, even if the image is not loadedHow do I populate hidden form field with a value set in Spring ControllerStyling Raw elements Generated from JSP tagds with Jquery MobileLimit resizing of images with explicitly set width and height attributeserror TLD use in a jsp fileJsp tld files cannot be resolved