0

I have this JSON string:

[{
    "dpeartment":"\u0418\u0437\u0431\u0435\u0440\u0435\u0442\u0435 \u043e\u0442\u0434\u0435\u043b",
    "position":"\u0418\u0437\u0431\u0435\u0440\u0435\u0442\u0435 \u043f\u043e\u0437\u0438\u0446\u0438\u044f"
 },{
    "dpeartment":"\u041c\u0422\u0426 \u0438 \u0441\u043a\u043b\u0430\u0434\u043e\u0432\u043e \u0441\u0442\u043e\u043f\u0430\u043d\u0441\u0442\u0432\u043e",
    "position":"\u0418\u0437\u0431\u0435\u0440\u0435\u0442\u0435 \u043f\u043e\u0437\u0438\u0446\u0438\u044f"
}]

It contains cyrillic characters that I want to convert to normal, readable UTF-8 encoded strings. How to decode the JSON and convert the cyrillic text to a readable UTF-8 string? Does java have any built-in classes for this?

1
  • Why do you want a UTF-8 String? Why does a regular UTF-16 java.lang.String not suffice? Commented Nov 11, 2012 at 20:31

1 Answer 1

1

Towards the bottom of http://json.org/ is a list of Java libraries for parsing and formatting JSON. org.json or json-simple for example.

How to decode the JSON and convert the cyrillic text to a readable UTF-8 string?

Any of them should expose the quoted strings in your JSON data bundle as java.lang.Strings which expose the strings content as a series of UTF-16 code-units. If you then want a byte[] with UTF-8 octets, see How to convert Strings to and from UTF8 byte arrays in Java .

Not the answer you're looking for? Browse other questions tagged or ask your own question.