The following problems occur during JSON parsing in Android:
Org. json. JSONException: Value & # xFEFF; of type java. lang. String cannot be converted to JSONObject
When you use Notepad ++ to set file encoding, use utf8 encoding. The above problem occurs. The reason is that the file contains the utf8 bom header information. You can use utf8 without BOM encoding.
For specific settings, see the following figure:
Supplement: bom format processing
| The code is as follows: |
Copy code |
String st = "UTF-8 bom format String content ";
Byte [] bytes = st. getBytes ("UTF-8 ");
Byte [] strs = new byte [bytes. length-3]; // remove the bom label of the content
Int j = 0;
If (bytes [0] =-17 & bytes [1] =-69 & bytes [2] =-65) {// header bytes of the bom file format
For (int I = 3; I <bytes. length; I ++ ){
Strs [j] = bytes [I];
J ++;
}
|
This is why the encoding problem is the same as the bom format encoding in php.