我试图在VB.NET中获取一个数组,但我遇到deserialize
的麻烦,我不知道我的格式是坏还是什么,但首先数据是std对象
Array
(
[0] => stdClass Object
(
[id] => 6797892
[marca] => xxx
[details] => yyy
[price] => rrr
[info] => Array
(
[0] => stdClass Object
(
[Items] => Array
(
[0] => stdClass Object
(
[Por] => 1
[$$hashKey] => 03F
)
)
[Tipo] => mouse
[price] => 1.65
[$$hashKey] => 03D
)
[1] => stdClass Object
(
[Items] => Array
(
[0] => stdClass Object
(
[Por] => o
[$$hashKey] => 03J
)
)
[Tipo] => teclado
[price] => 1.65
[$$hashKey] => 03H
)
)
[$$hashKey] => 03B
)
)
接下来我使用json_encode(在php中):结果是:
[{"Id":"6797904","marca":"xxx","Pais":"yyy","Liga":"rrr","Jornada":"3","info":[{"Items":[{"Por":"1","Cuota":"2.25","$$hashKey":"03I"}],"Tipo":"mouse","price":2.25,"$$hashKey":"03G"}],"$$hashKey":"03E"}]
并使用
....
file_put_contents($file, print_r($current, true) );
...
我将其保存在items.txt
中,然后将其加载到vb.net中,但我不知道使用以下内容转换为数组的正确方法是什么:
Dim str As JArray = JArray.Parse(TextBox1.Text)
Dim results As Object = str("Id").ToString
答案 0 :(得分:0)
将答案格式加入其中。
此处使用print_r
不正确。
...
file_put_contents($file, print_r($current, true) );
...
根据php.net print_r
的定义:
print_r - 打印有关变量的人类可读信息。
这意味着添加了额外的字符以使其对人类可读,但对于机器则不然。它甚至会创建无效的JSON,导致VB.NET生成错误。
将您的代码更新为
...
file_put_contents($file,$current);
...
它应该可行