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

[json-core] Add SimpleMapper API to core to make it easier for reading/writing simple Maps, Lists etc #307

Merged
merged 1 commit into from
Dec 12, 2024

Conversation

rbygrave
Copy link
Contributor

 static final SimpleMapper simpleMapper = SimpleMapper.builder().build();

  void test() {

    Map<String, Long> map = new LinkedHashMap<>();
    map.put("one", 45L);
    map.put("two", 93L);

    String asJson = simpleMapper.toJson(map);
    assertThat(asJson).isEqualTo("{\"one\":45,\"two\":93}");

    Map<String, Object> mapFromJson = simpleMapper.fromJsonObject(asJson);

    assertThat(mapFromJson).containsKeys("one", "two");
    assertThat(mapFromJson.toString()).isEqualTo("{one=45, two=93}");
  }

@rbygrave rbygrave requested a review from SentryMan December 12, 2024 10:01
@rbygrave rbygrave self-assigned this Dec 12, 2024
@rbygrave rbygrave merged commit db77d90 into main Dec 12, 2024
9 checks passed
@rbygrave rbygrave deleted the feature/core-simpleMapper branch December 12, 2024 10:03
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

Successfully merging this pull request may close these issues.

1 participant