Search code examples
javascriptjavajsonobject

Deserializing Json Object in java


I cannot figure it out, I should deserialize a json object of this type:

{
    "value":"integer",
    "total":"1",
    "records":"138",
    "rows":[
    {
        "value1":6,
        "value2":true,
        "bool":true,
        "floatNumber":"140.41",
        "floatNumber2":"28.7",
        "floatNumber3":"140.41",
        "cssClassName":"",
        "date":"19/03/2022",
        "UTCdate":"2016-03-22T00:00:00+0000",
        "UTCdate2":"2016-03-24T20:45:25+0000"
    },
    {
        "value1":6,
        "value2":true,
        "bool":true,
        "floatNumber":"140.41",
        "floatNumber2":"28.7",
        "floatNumber3":"140.41",
        "cssClassName":"",
        "date":"19/03/2022",
        "UTCdate":"2016-03-22T00:00:00+0000",
        "UTCdate2":"2016-03-24T20:45:25+0000"
    }]
} 

but I do not know how to do. I wish that this item was added to my class, pointing to what value to assign the corresponding property.

I tried to use Flexjson library but didn't saw any function that will let me what i want to do.

Where to start?

PS: I never serialized an object to JSON, so I do not know how it works.


Solution

  • You can go through this tutorial. Hope it will help you.

    1. How to convert Java object to / from JSON (Jackson)
    2. https://dzone.com/articles/deserializing-json-java-object