Serafins
Serafins

Reputation: 1247

ZERO WIDTH SPACE in Json

I'm trying to deal with JSON and I found /u200b (Zero width space) right before double values. I cant pares it right now, even setting the filed type to String. Here I can easily remove it, but how to deal with downloading content from a server?

  String testJson = "{" +
            "    \"name\": \"Aarhus\"," +
            "    \"latitude\": \u200B56.3," +
            "    \"longitude\": \u200B10.619," 
            " }";

Upvotes: 0

Views: 7095

Answers (2)

Jon Jonsson
Jon Jonsson

Reputation: 87

You can try to use Jackson, it has many options such as FAIL_ON_UNKNOWN_PROPERTIES and ACCEPT_SINGLE_VALUE_AS_ARRAY. It might help

Upvotes: 0

Aleksei Egorov
Aleksei Egorov

Reputation: 801

Use the following replacement if you already have your data in a string.

testJson =testJson.replaceAll("\u200B", "");

If you need to load data from url first, then some clever ways are discussed here: Read url to string in few lines of java code

Upvotes: 4

Related Questions