Java parsing PHP function JSON_ Encode Unicode encoding problem

During Android development, there is a coding problem when interfacing with the server-side interface. The data obtained from the server-side is "\ u8bbe \ u59071id - \ u8bbe \ u59071 \ u540d \ u79f0; \ u8bbe \ u59073id - \ u8bbe \ u59073 \ u540d \ u79f0; \ u8bbe \ u59077id - \ u8bbe \ u59077 \ u540d \ u79f0". The interface is through JSON in PHP functions_ The code returned after encoding is passed through Java. Net on the client net. URLdecoder. Decode () decoding doesn't work, but directly copying the above string into the decode () method can decode normally. It doesn't work after UTF-8 encoding the received string. Finally, search the relevant information on the Internet to find a solution.

1、 JSON_ Encode function:

json_ Encode -- JSON encodes variables.

Description: String JSON_ Encode ($value) returns the JSON form of the value value.

Parameter: the value to be encoded can be any data type except resource type

This function can only accept UTF-8 encoded data

Return value: if the encoding is successful, a string in JSON is returned.

2、 The client decodes in Java language:

The first method

Just use the unescapeanicode () method to decode it directly.

  2. Using JSON_ simple. Jar package parsing

Download address: http://www.jb51.net/softs/455885.html

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>