Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

JsonObject deserialisation #883

Copy link
Copy link
@ashj11

Description

@ashj11
Issue body actions

I am using JsonReader to read json bytes to JsonObject. What is the equivalent for msgpack?
Below is the code we are using for desrialising json to JsonObject.

JsonReader jsonReader = Json.createReader(content);
            object =  jsonReader.readObject();
            jsonReader.close();

For deserialising JsonObject msgpack bytes to JsonObject in java, I have tried ObjectMapper, but it fails with

com.fasterxml.jackson.databind.exc.InvalidDefinitionException: Cannot find a deserializer for non-concrete Map type [map type; class jakarta.json.JsonObject, [simple type, class java.lang.String] -> [simple type, class jakarta.json.JsonValue]]

Below is the sample i have tried, which produces above error. What is the right way to deserialise a JsonObject in msgpack?

String nodeInfo = "{\n" +
        "\t\"nodeType\": \"directory\"\n" +
        "}";
    
    // Create JsonObject from nodeInfo string
    JsonObject node;
    try (jakarta.json.JsonReader jsonReader = jakarta.json.Json.createReader(new ByteArrayInputStream(nodeInfo.getBytes(StandardCharsets.UTF_8)))) {
        node = jsonReader.readObject();
    }

    // Create MessagePack data
    ObjectMapper msgpackMapper = new ObjectMapper(new MessagePackFactory());
    byte[] bytes = msgpackMapper.writeValueAsBytes(node);

From #465 (comment), it looks like with ObjectMapper, JsonObject deserialisation used to work before. But it does not work now. Could you please suggest a solution?

Versions used:
jackson version - 2.15.3
msgpack version - 0.9.7

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.