-1

My json structure is

{
    "GAME_CUSTOMIZE": {
        "GAME_CODE": "MOCK12V2.0",
        "RESULT": {
            "response": [
                {
                    "id": "PLAYER1",
                    "value": "WERYT"
                },
                {
                    "id": "PLAYER2",
                    "value": "QEWRET"
                },
                {
                    "id": "PLYAER3",
                    "value": "765422"
                }
            ]
        }
    }
}'

My Pojo object using for mapping is,

import com.fasterxml.jackson.annotation.JsonProperty;

@JsonProperty("GAME_CODE")
private String gameCode;
@JsonProperty("RESULT")
private String responseJson;

When trying to assign the "RESULT" complete json to string, getting empty after conversion from json to Java object. Have tried JsonRawValue annotation also. And tried with responseJson as Object type instead of string. I want to get the RESULT Json to Java string or Object property.

aarav
  • 230
  • 1
  • 4
  • 21

1 Answers1

0

The default mapping for a JSON object is a LinkedHashMap<String, Object>. The simple solution would be to change the type of responseJson to that.

Mapping to a String (containing the original JSON serialization of the object) might make sense, but I don't know if it is implementable. Mapping to java.lang.Object makes no sense.

UPDATE - the following Q&A explains how to deserialize an object as a string:

Community
  • 1
  • 1
Stephen C
  • 698,415
  • 94
  • 811
  • 1,216