---
title: "JSONException: java.lang.String cannot be converted to JSONObject"
author: "jguangyou"
date: "2012-09-19T11:36:16Z"
tags: []
categories: ["移动开发"]
slug: "jsonexception-java-lang-string-cannot-be-converted-to-jsonobject"
draft: false
lastmod: "2012-09-19T11:36:16Z"
id: 1681262
url: "https://deep-fish.iteye.com/blog/1681262"
---

在用org.json.JSONObject 解析从网络获取的json数据时，遇到JSONException: java.lang.String cannot be converted to JSONObject，打印字符串，查看json字符串没有问题，郁闷！！！！在百度和google的支持下，终于找到问题，造成问题的原因是在编写json文件的时候，采用utf-8编码，utf8有个BOM格式，干掉这个格式就ok了。如何干掉呢？

very easy，看图：

![](http://dl.iteye.com/upload/attachment/0074/0338/afd65666-7cca-3fe3-ae4a-48399985f680.png)