Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/unity3d/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
带空格的JSON值_Json_Unity3d - Fatal编程技术网

带空格的JSON值

带空格的JSON值,json,unity3d,Json,Unity3d,我在Unity上开发并使用SimpleJSON库读取JSON。因此,我做了以下工作: JSONNode datos = JSON.Parse (jsonString); for (int i = 0; i < datos["posts"].Count; i++) { string aux = datos ["posts"] [i] ["text"]; } 我看到两种可能的情况: 最可能的情况是,http服务器的响应已经在JSON字符串中删除了空格,或者您在解析之前将其删除了

我在Unity上开发并使用SimpleJSON库读取JSON。因此,我做了以下工作:

JSONNode datos = JSON.Parse (jsonString); 
for (int i = 0; i < datos["posts"].Count; i++) {
    string aux = datos ["posts"] [i] ["text"];
 }

我看到两种可能的情况:

  • 最可能的情况是,http服务器的响应已经在JSON字符串中删除了空格,或者您在解析之前将其删除了

  • SimpleJSON在不明确命名类型时执行此操作。我的意思是:你可以通过以下方式获得字符串:

  • 字符串aux=datos[“posts”][i][“text”]

    但也许你应该这样做:

    string aux = datos.AsObject ["posts"].AsArray [i].AsObject ["text"].Value;
    
    还要尝试解析到JSONObject:

    JSONObject datos = JSON.Parse (jsonString).AsObject; 
    

    我认为这不是图书馆的问题。您能否提供更相关的代码-如何检索
    jsonString
    变量?
    unity
    是错误的标记。也许你的意思是
    unity3d
    ?我每天都使用SimpleJSON,它不会删除空格。在解析之前,需要对字符串进行一些处理。
    JSONObject datos = JSON.Parse (jsonString).AsObject;