Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/vb.net/16.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
Vb.net 如何在VB中定制HTTP JSON POST请求格式_Vb.net_Linq_Post_Json.net - Fatal编程技术网

Vb.net 如何在VB中定制HTTP JSON POST请求格式

Vb.net 如何在VB中定制HTTP JSON POST请求格式,vb.net,linq,post,json.net,Vb.net,Linq,Post,Json.net,这是最终结果{“recordType”:“b”,“recordNumber”:1550316,“pickupLocation”:“de”} InputJson=“{”“记录类型”“:”“b”“记录编号”“:”“1550316”“pickupLocation”“:”“de”“}” 返回=“httpStatus”:400, “名称”:“无效的JSON”, “说明”:“JSON对象缺少字段或字段具有无效数据” 我需要帮助正确格式化我的post请求,使其看起来像以下内容。请注意,recordnumber

这是最终结果{“recordType”:“b”,“recordNumber”:1550316,“pickupLocation”:“de”}

InputJson=“{”“记录类型”“:”“b”“记录编号”“:”“1550316”“pickupLocation”“:”“de”“}”

返回=“httpStatus”:400, “名称”:“无效的JSON”, “说明”:“JSON对象缺少字段或字段具有无效数据”

我需要帮助正确格式化我的post请求,使其看起来像以下内容。请注意,recordnumber值没有引号。->

{"recordType": "b", "recordNumber": 1550316, "pickupLocation": "de"}

TY:)

我猜recordId是一种字符串类型

选项1:创建一个具体的类并远离匿名类型

Public Class YourClass
    Public Property recordType As String
    Public Property recordNumber As Integer
    Public Property pickupLocation As String
End Class
    Dim input As Object = New With {
                .recordType = "b",
                .recordNumber = System.Convert.ToInt32(recordId),
                .pickupLocation = "de"
    }
选项2:如果您确定这是一个整数,那么在初始化匿名类型时只需将其转换为整数即可

Public Class YourClass
    Public Property recordType As String
    Public Property recordNumber As Integer
    Public Property pickupLocation As String
End Class
    Dim input As Object = New With {
                .recordType = "b",
                .recordNumber = System.Convert.ToInt32(recordId),
                .pickupLocation = "de"
    }

感谢您回答N0Alias。选项2:设法除去recordNumber->“{”“recordType”“:”“b”“recordNumber”“:1550316”“pickupLocation”“:”“de”“}”周围的引号。你知道如何修复{}外部的引号并用{}替换内部的双引号吗