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

1
  • You're missing a POJO for GAME_CUSTOMIZE and RESULT (You have an object within a object) Commented Apr 19, 2017 at 4:16

1 Answer 1

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:

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.