Skip to content

🐞 Unicode gets double escaped when serializing to json #334

Closed
@lprichar

Description

@lprichar

Is there an existing issue for this?

  • I have searched the existing issues

Current Behavior

.ToJson() converts ú to \\u00f

Expected Behavior

.ToJson() should convert ú to \u00f

Steps To Reproduce

The following test should pass:

[Test]
public void Test_Unicode_CandidateNames()
{
    var candidateName = new Language("Raúl", "en");
    var candidate = new Candidate(
        "candidate-1",
        new InternationalizedText(new[] { candidateName }),
        string.Empty,
        string.Empty,
        false);

    List<Candidate> candidates = new List<Candidate>
    {
        candidate
    };

    var result = new Manifest(
        "test-manifest",
        ElectionType.general,
        DateTime.Now,
        DateTime.Now,
        new GeopoliticalUnit[] { },
        new Party[] { },
        candidates.ToArray(),
        new ContestDescription[] { },
        new BallotStyle[] { },
        new InternationalizedText(new Language[] { }),
        new ContactInformation("na"));

    var json = result.ToJson();
    Assert.IsTrue(json.Contains("\"value\":\"Ra\\u00fal\""));
}

Environment

- OS:

Anything else?

No response

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingtriageWaiting to be triaged

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions