【发布时间】:2014-12-31 15:33:11
【问题描述】:
如何在 dotnet 3.5 中对这个数组结构进行 json 序列化?
<?php
$response = array(
'file_version' => 2,
'files' =>
array(
array(
'file_name' => 'test1.exe',
'url' => 'http://127.0.0.1/heartkey/files/test1.exe',
'path' => 'images\filename\\'
),
array(
'file_name' => 'test2.exe',
'url' => 'http://127.0.0.1/heartkey/files/test2.exe',
'path' => 'images\filename\\'
),
array(
'file_name' => 'test3.exe',
'url' => 'http://127.0.0.1/heartkey/files/test3.exe',
'path' => 'images\filename\\'
)
),
'files_max_size' => 3000
);
$json = json_encode( $response );
echo $json;
我找到了基本方法,但我不知道如何在 vb 中表示, 我尝试使用数组并嵌套字典,但没有运气。 我的 vb.net 知识很基础。
这就是我所拥有的:
Imports System.Web.Script.Serialization
Partial Class _Default
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load
Dim info As Dictionary(Of String, Dictionary(Of String, String))
'info.Add("files", New Dictionary(Of String, String))
Dim serializer As New JavaScriptSerializer()
Dim serializedResult = serializer.Serialize(info)
Response.Write(serializedResult)
End Sub
End Class
【问题讨论】:
-
您的 PHP 代码正在将您的对象编码为 Json 对象,这是您要找的吗?