my json is in below format and for some reason i have to convert it to a string using jackson.
{
"responseCode": 200,
"output": [
{
"address": {
"address1": "string",
"address2": "string",
"addressId": "1543",
"city": "string",
"fxGeocode": "string",
"houseNumber": "string",
"isActive": true,
"postalCode": "string",
"state": "string",
"streetName": "string",
"zip": "string"
},
"city": "string",
"externalIds": [
{
"externalId": "string",
"externalIdDocId": "676273d0-ebf7-4f46-bd5a-e8af09589646",
"partyRoleExternalIdType": "string"
}
],
"name": "string",
"organizationRoleId": 975,
"zip": "string"
},
{
"address": {
"address1": "string",
"address2": "string",
"addressId": "1767",
"city": "string",
"fxGeocode": "string",
"houseNumber": "string",
"isActive": true,
"postalCode": "string",
"state": "string",
"streetName": "string",
"zip": "string"
},
"city": "string",
"externalIds": [
{
"externalId": "string",
"externalIdDocId": "248badd9-8b5d-4b9d-8c00-055f0afacdfc",
"partyRoleExternalIdType": "string"
}
],
"name": "string",
"organizationRoleId": 976,
"zip": "string"
}
],
"totalCount": 2
}
After unmarshalling it to string using jackson it is converted in string as below.
{output=[{address={address1=string, address2=string, addressId=1543, city=string, fxGeocode=string,
houseNumber=string, isActive=true, postalCode=string, state=string, streetName=string, zip=string},
city=string, externalIds=[{externalId=string, externalIdDocId=676273d0-ebf7-4f46-bd5a-e8af09589646,
partyRoleExternalIdType=string}], name=string, organizationRoleId=975, zip=string}, {address=
{address1=string, address2=string, addressId=1767, city=string, fxGeocode=string,
houseNumber=string, isActive=true, postalCode=string, state=string, streetName=string, zip=string},
city=string, externalIds=[{externalId=string, externalIdDocId=248badd9-8b5d-4b9d-8c00-055f0afacdfc,
partyRoleExternalIdType=string}], name=string, organizationRoleId=976, zip=string}],
responseCode=200, totalCount=2}
how to i convert it back to the json format in java? Should i create a class for the same to marshal it back?
{output=[{address ...
looks like a result oftoString
method invoked onMap
. – Michał Ziober