Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I have this JSON string:

[{
    "dpeartment":"u0418u0437u0431u0435u0440u0435u0442u0435 u043eu0442u0434u0435u043b",
    "position":"u0418u0437u0431u0435u0440u0435u0442u0435 u043fu043eu0437u0438u0446u0438u044f"
 },{
    "dpeartment":"u041cu0422u0426 u0438 u0441u043au043bu0430u0434u043eu0432u043e u0441u0442u043eu043fu0430u043du0441u0442u0432u043e",
    "position":"u0418u0437u0431u0435u0440u0435u0442u0435 u043fu043eu0437u0438u0446u0438u044f"
}]

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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
1.2k views
Welcome To Ask or Share your Answers For Others

1 Answer

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 .


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share

548k questions

547k answers

4 comments

86.3k users

...