Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/vb.net/15.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类的Json_Json_Vb.net_Class - Fatal编程技术网

来自VB.net类的Json

来自VB.net类的Json,json,vb.net,class,Json,Vb.net,Class,我编辑我的代码。我正在尝试基于这些类序列化Json文件。我的缺点是使用“Concept”类,它是一个文章列表,我必须从“Line”表中获取,并将字段值序列化到“Concept”类的公共属性中。我发表了我到目前为止所做的事情。任何帮助+建议都将不胜感激 Public Class Folio Public Property serie As String Public Property folio As String End Class Public Class Emisor

我编辑我的代码。我正在尝试基于这些类序列化Json文件。我的缺点是使用“Concept”类,它是一个文章列表,我必须从“Line”表中获取,并将字段值序列化到“Concept”类的公共属性中。我发表了我到目前为止所做的事情。任何帮助+建议都将不胜感激

  Public Class Folio
    Public Property serie As String
    Public Property folio As String
End Class

Public Class Emisor
    Public Property nit As String
End Class

Public Class Receptor
    Public Property nombre As String
    Public Property nit As String
    Public Property calle As String
    Public Property ciudad As String
    Public Property estado As String
    Public Property pais As String
    Public Property regimen_fiscal As String
    Public Property perfil As String
    Public Property email As String
    Public Property telefono As String
End Class

Public Class Concepto
    Public Property cantidad As String
    Public Property unidad As Integer
    Public Property concepto As String
    Public Property pu As String
    Public Property desc As Integer
    Public Property impuesto As String
    Public Property tasa As String
    Public Property ni As String
    Public Property importe As String
End Class

Public Class Retencione
    Public Property impuesto As String
    Public Property importe As String
    Public Property tasa As Integer
    Public Property clave As String
End Class

Public Class FacturaE
    Public Property folio As Folio
    Public Property emisor As Emisor
    Public Property receptor As Receptor
    Public Property referencia As String
    Public Property fecha_vencimiento As DateTime
    Public Property moneda As String
    Public Property moneda_vcambio As String
    Public Property subtotal As String
    Public Property impuestos As String
    Public Property descuentos As String
    Public Property total As String
    Public Property metodo_pago As String
    Public Property forma_pago As String
    Public Property condicionpago As String
    Public Property leyenda_fiscal As Integer
    Public Property conceptos As List(Of Concepto)
    Public Property retenciones As List(Of Retencione)
    Public Property huella As String
End Class
代码

Dim facturaJson As New FacturaE
        Dim bsObj As FacturaE = New FacturaE() With {
                        .folio = New Folio() With {
        .folio = "0000007",
        .serie = "E"},
                        .emisor = New Emisor() With {
        .nit = "379487548-7"},
                        .receptor = New Receptor() With {
        .nombre = "RESTAURANTE Y CAFETERIA EL GORDO",
        .nit = "37947878-5",
        .calle = "CR 15 7 43",
        .ciudad = "CURUMANI",
        .estado = "CESAR",
        .pais = "COL",
        .regimen_fiscal = "F",
        .perfil = "R",
        .email = "elcorreo@hotmail.com",
        .telefono = "3115827410"},
        .referencia = "0977245487", ' verificar a que hace "referencia"
        .fecha_vencimiento = "2020-10-21T00:00:00",
        .moneda = "COP",
        .moneda_vcambio = "1",
        .subtotal = "863470.68",
        .impuestos = "150379.43",
        .descuentos = "OO",
        .total = "",  ' SUMA DE IMPUESTOS, DESCUENTO, BASE
        .metodo_pago = "1",
        .forma_pago = "PUE",
        .condicionpago = "1",
        .leyenda_fiscal = 0},
                        .conceptos = New Concepto() With {
        .cantidad = "5.00",
        .unidad = 0,
        .concepto = "SOBRE DE SEGURIDAD",
        .pu = "5714.290000",
        .desc = "0",
        .impuesto = "5428.58",
        .tasa = "19.00",
        .ni = "PANDA17",
        .importe = "5714.290000"}

        ' Conceptos (Array) desde el detalle de conceptos (Articulos) en la factura
        ' tomados desde la capa de datos mediante SQL Debe generarse así en el JSON 
        ' usando la clase FacturaE --> Public Property: conceptos As Concepto()
        ' de la clase Publica Concepto.
        '------------------------------------<

        '.conceptos [
        '   {
        '       "cantidad": "3.00",
        '       "unidad": 0,
        '       "concepto": "PC J1 BLANCO BX200 UND",
        '       "pu": "43781.510000",
        '       "desc": 0,
        '       "impuesto": "24955.46",
        '       "tasa": "19.00",
        '       "ni": "BJ1",
        '       "importe": "131344.530000"
        '   },
        '   {
        '       "cantidad": "3.00",
        '       "unidad": 0,
        '       "concepto": "TAPABOCAS HOUSE CAJA X50 UND",
        '       "pu": "24000.000000",
        '       "desc": 0,
        '       "impuesto": "0.00",
        '       "tasa": "0.00",
        '       "ni": "7707320620811",
        '       "importe": "72000.000000"
        '   }
        '],

        Dim str As String = JsonConvert.SerializeObject(bsObj, Formatting.Indented)
        ' Exporting .json file
        System.IO.File.WriteAllText("E:\5-000007.json", str)
Dim facturaJson作为新FacturaE
将bsObj标注为FacturaE=新FacturaE(),带有{
.folio=带有{
.folio=“0000007”,
.serie=“E”},
.emissor=新的emissor(),带有{
.nit=“379487548-7”},
.receptor=带有{
.nombre=“餐厅Y自助餐厅EL GORDO”,
.nit=“37947878-5”,
.calle=“CR 15 7 43”,
.ciudad=“CURUMANI”,
.estado=“CESAR”,
.pais=“COL”,
.F_财政=“F”,
.perfil=“R”,
.email=”elcorreo@hotmail.com",
.telefono=“3115827410”},
.referecia=“0977245487”,验证是否为“参考”
.fecha_venciiento=“2020-10-21T00:00:00”,
.moneda=“COP”,
.moneda_vcambio=“1”,
.subtotal=“863470.68”,
.impustos=“150379.43”,
.descuntos=“OO”,
.total=“”,“不公平的情况下,不公平的,基本的”
.metodo_pago=“1”,
.forma_pago=“PUE”,
.condicinpago=“1”,
.leyenda_财政=0},
.conceptos=带有{
.cantidad=“5.00”,
.unidad=0,
.concepto=“SOBRE DE SEGURIDAD”,
.pu=“5714.290000”,
.desc=“0”,
.impusto=“5428.58”,
.tasa=“19.00”,
.ni=“PANDA17”,
.import=“5714.290000”}
“概念(阵列)是一个事实
“tomados desde la capa de datos mediante SQL dese generarse asíen el JSON
“usando la clase FacturaE-->公共财产:概念作为概念()
“公共概念课程”。
'------------------------------------<
"概念[
'   {
"康蒂达:"3.00,,
"unidad":0,,
“概念”:“PC J1 BLANCO BX200 UND”,
"pu:"43781.510000",,
““描述”:0,
""插补":"24955.46",
"塔萨:"19.00,,
"ni":"BJ1",
“进口”:“131344.530000”
'   },
'   {
"康蒂达:"3.00,,
"unidad":0,,
“concepto”:“CAJA X50 UND塔帕博卡斯之家”,
"普":"24000.000000",
““描述”:0,
““不公平”:“0.00”,
“塔萨”:“0.00”,
"ni":"7707320620811",
“进口”:“72000.000000”
'   }
'],
Dim str As String=JsonConvert.SerializedObject(bsObj,格式化.缩进)
'正在导出.json文件
System.IO.File.WriteAllText(“E:\5-000007.json”,str)

欢迎!请考虑添加<代码> VB.NET<代码>和/或任何其他适当的标签。谢谢你,祝你好运!需要明确的是,您的问题在于将json反序列化到您创建的类结构中?你能展示你到目前为止所做的尝试吗?谢谢你的回答,不,问题不是json的反序列化,我发布的json是我必须从Vb.net序列化的模型,我使用了一个在线工具()来创建基于json的类。我的基本问题是,我不知道如何开始使用这些类构建json。我尝试过几种方法,但没有开始。Dim folios As New Folio folios=新Folio With folios Dim Folio As New List(Folio)Folio End With End With End With Dim str As String=JsonConvert.serialized对象(folios,Formatting.Indented)'exportamos a la ruffara destino System.IO.File.WriteAllText(“E:\JSON1.json”,str)您应该将该代码编辑到问题中,而不是将其作为注释发布。