Squadless
asked on
How to parse custom JSON to POJO java
Hi,
I have a situation where I'm getting a post with a json in format of
I need to create an object that has 2 fields: 1 - String importantThing.. and THE REST OF THE JSON PAYLOAD.
object mapper barfs when jackson tries to deserialize the rest of the json payload..
I would like to create an object where i have the important thing be a string field, and one STRING to represent THE REST of the json payload (raw form even).. how is this possible? I've tried to create a pojo with a string and a byte[] but cant seem to feed the remainder of the json to that byte[]... any ideas? or am i doing this wrong? (i dont care about the metadata, i just need to convert it to a string or clob or whatever and store it - it wont be used)
So in other words how to say "take the important field and save it as string, then take EVERYTHING ELSE and save it as "x"
I have a situation where I'm getting a post with a json in format of
{
"importantThing": "value",
"metadata":
{
"param1": "info1",
"param2": "info2",
"param3": "info3"
... maybe an array in here or another object.. i dont know this part.
}
}
I need to create an object that has 2 fields: 1 - String importantThing.. and THE REST OF THE JSON PAYLOAD.
object mapper barfs when jackson tries to deserialize the rest of the json payload..
I would like to create an object where i have the important thing be a string field, and one STRING to represent THE REST of the json payload (raw form even).. how is this possible? I've tried to create a pojo with a string and a byte[] but cant seem to feed the remainder of the json to that byte[]... any ideas? or am i doing this wrong? (i dont care about the metadata, i just need to convert it to a string or clob or whatever and store it - it wont be used)
So in other words how to say "take the important field and save it as string, then take EVERYTHING ELSE and save it as "x"
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Or if you don't care about the meta, then don't map it to a pojo field. It will get dropped if your deserialise config ignores unknown props.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.