Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for other JSON libraries #262

Open
FeldrinH opened this issue Apr 20, 2023 · 1 comment
Open

Support for other JSON libraries #262

FeldrinH opened this issue Apr 20, 2023 · 1 comment

Comments

@FeldrinH
Copy link

It seems that it is currently only possible to pass JSON in and get JSON out as Jackson JsonNode. It would be nice if it was possible to use JSON representations from other libraries as well, such as Gson's JsonElement.

@wnm3
Copy link
Member

wnm3 commented Apr 20, 2023

This could be accomplished by a shim that gets the String from one form and parses into the other... not sure if this should be done in this library of as an external wrapper using something like this:

import com.fasterxml.jackson.databind.JsonNode;
import com.google.gson.JsonElement;
import com.google.gson.JsonParser;

static ObjectMapper _objectMapper = new ObjectMapper();

public static class GSONConverter {
   static public JsonElement toGSON(JsonNode node) throws Exception {
      return JsonParser.parseString(_objectMapper.writeValueAsString(node));
   }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants