反序列化JSON时无法识别的转义序列错误

时间:2013-07-02 09:14:42

标签: ios objective-c json foursquare

我从location获取foursquare api数据,然后将此数据传递给webservice以插入数据库。

现在,例如当我获得墨西哥城市的位置数据时,其中有一些特殊字符会产生以下错误: -

 Unrecognized escape sequence. (13443):

    "StackTrace":"   at System.Web.Script.Serialization.JavaScriptObjectDeserializer.AppendCharToBuilder(Nullable`1 c, StringBuilder sb)
                     at System.Web.Script.Serialization.JavaScriptObjectDeserializer.DeserializeString()
                     at System.Web.Script.Serialization.JavaScriptObjectDeserializer.DeserializeInternal(Int32 depth)
                     at System.Web.Script.Serialization.JavaScriptObjectDeserializer.DeserializeDictionary(Int32 depth)
                     at System.Web.Script.Serialization.JavaScriptObjectDeserializer.DeserializeInternal(Int32 depth)
                     at System.Web.Script.Serialization.JavaScriptObjectDeserializer.BasicDeserialize(String input, Int32 depthLimit, JavaScriptSerializer serializer)
                     at System.Web.Script.Serialization.JavaScriptSerializer.Deserialize(JavaScriptSerializer serializer, String input, Type type, Int32 depthLimit)
                     at System.Web.Script.Serialization.JavaScriptSerializer.Deserialize[T](String input)
                     at System.Web.Script.Services.RestHandler.ExecuteWebServiceCall(HttpContext context, WebServiceMethodData methodData)","ExceptionType":"System.ArgumentException"}

如果我选择 USA India 的任何其他位置,那么它可以正常工作并且数据已成功插入。

我的JSON字符串是 -

[
  {
    "city":"Cupertino",
    "add":"1 Infinite Loop",
    "ccode":"US",
    "vid":"49b15db9f964a520d5521fe3",
    "img":"https://foursquare.com/img/categories_v2/building/default_",
    "state":"CA",
    "lat":37.33233,
    "lang":-122.0312,
    "latitude2":37.33165299780678,
    "dist":86,
    "pcode":"95014",
    "cross":null,
    "country":"United States",
    "name":"Apple Inc.",
    "longitude2":-122.0307230411742
  },
  {
    "city":"Cupertino",
    "add":"2 Infinite Loop",
    "ccode":"US",
    "vid":"4aba52aef964a520e08020e3",
    "img":"https://foursquare.com/img/categories_v2/building/default_",
    "state":"CA",
    "lat":37.33233,
    "lang":-122.0312,
    "latitude2":37.33254491081593,
    "dist":53,
    "pcode":"95014",
    "cross":null,
    "country":"United States",
    "name":"Apple - Infinite Loop 2",
    "longitude2":-122.0306564324852
  }
]

我找不到原因。

请帮助我。

感谢。

0 个答案:

没有答案