question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

improper utf-8 handling in json-unit-spring

See original GitHub issue

Describe the bug

  • JsonUnit 2.11.0
  • BringBoot 2.2.0.RELEASE

When using json-unit with rest-assured all works fine:

        given(specification)
                .with()
                .accept(MediaType.APPLICATION_JSON_VALUE)
                .queryParam("produktIds", PreisApiData.PRODUKT_IDS)

                .when()
                .get("preise")

                .then()
                .statusCode(HttpStatus.OK.value())

                .assertThat()
                .contentType(MediaType.APPLICATION_JSON_VALUE)
                .body(jsonEquals(PreisApiData.PREIS_DTOS));

But writing the same test with json-unit-spring and mock-mvc causes encoding issues:

        mockMvc.perform(get("/preise")
                .accept(MediaType.APPLICATION_JSON)
                .param("produktIds", PreisApiData.PRODUKT1_ID.toString(), PreisApiData.PRODUKT2_ID.toString()))
                .andExpect(status().isOk())
                .andExpect(content().contentTypeCompatibleWith(MediaType.APPLICATION_JSON))
                .andExpect(json().isEqualTo(PreisApiData.PREIS_DTOS));

->

Different value found in node "[0].currency", expected: <"€"> but was: <"€">.
Comparison Failure: 
Expected :€
Actual   :€

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
lukas-krecancommented, Nov 2, 2019

Good catch, thanks, will fix it.

0reactions
lukas-krecancommented, Nov 2, 2019

Released as 2.11.1

Read more comments on GitHub >

github_iconTop Results From Across the Web

Spring MVC UTF-8 Encoding - java - Stack Overflow
Thanks to McDwell, I just tried out using "\u00f6lm" instead of "ölm" in my controller and the encoding issue on the JSP page...
Read more >
UTF-8: The Secret of Character Encoding - HTML Purifier
This document will walk you through determining the encoding of your system and how you should handle this information. It will stay away...
Read more >
What is UTF-8 Encoding? A Guide for Non-Programmers
UTF-8 is a Unicode character encoding method. This means that UTF-8 takes the code point for a given Unicode character and translates it...
Read more >
Haskell with UTF-8 - Serokell
Bad news: something is wrong. Good news: it is not necessarily an issue with your code, it can be one of the libraries...
Read more >
Encoding.UTF8 Property (System.Text) - Microsoft Learn
It displays the UTF-16 code units of each character and determines the number of bytes required by a UTF-8 encoder to encode the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found