PC SOFT

FORUMS PROFESSIONNELS
WINDEVWEBDEV et WINDEV Mobile

Accueil → WINDEV 2024 → Create JSON stucture
Create JSON stucture
Débuté par Leo Bidi, 12 avr. 2018 21:39 - 1 réponse
Posté le 12 avril 2018 - 21:39
Hi, I need some help to create the next json structure to then send to a web service.

{
  "originalNumber": "A:537",
  "encabezado": {
    "receptor": {
      "tipoDocRecep": "2",
      "docRecep": "110160220010"
    },
    "idDoc": {
      "tipoCFE": "111",
      "fchEmis": "2018-03-28",
      "fmaPago": "1"
    },
    "emisor": {
      "cdgDGISucur": "2",
      "rucEmisor": "110097770012"
    },
    "totales": {
      "mntPagar": "2200",
      "tpoMoneda": "UYU"
    }
  },
  "referenceDocument": "null",
  "referenceDetail": "null",
  "detalle": [
    {
      "nroLinDet": "1",
      "precioUnitario": "1000",
      "descuentoPorcentaje": "0.0",
      "nomItem": "Prueba de factura",
      "uniMed": "N/A",
      "cantidad": "1",
      "montoDescuento": "0.00",
      "indFact": "2",
      "montoItem": "1000"
    },
    {
      "nroLinDet": "2",
      "precioUnitario": "1000",
      "descuentoPorcentaje": "0.0",
      "nomItem": "otro renglon",
      "uniMed": "N/A",
      "cantidad": "1",
      "montoDescuento": "0.00",
      "indFact": "2",
      "montoItem": "1000"
    }
  ]
}


is there any object I can use to manage this or must I use a simple string ??
I am using WinDev 22

Thanks so much.
Membre enregistré
940 messages
Popularité : +66 (68 votes)
Posté le 13 avril 2018 - 10:04
Hi,

you could use a Variant , like this :

_json_data is a Variant

_json_data.originalNumber="A:537"
_json_data.encabezado.receptor.tipoDocRecep="2"
_json_data.encabezado.receptor.docRecep="110160220010"
_json_data.encabezado.idDoc.tipoCFE="111"
_json_data.encabezado.idDoc.fchEmis="2018-03-28"
_json_data.encabezado.fmaPago="1"
_json_data.encabezado.emisor.cdgDGISucur="2"
_json_data.encabezado.emisor.rucEmisor="110097770012"
_json_data.encabezado.totales.mntPagar="2200"
_json_data.encabezado.totales.tpoMoneda="UYU"

_json_data.referenceDocument="null"
_json_data.referenceDetail="null"

_json_data.detalle[1].nroLinDet="1"
_json_data.detalle[1].precioUnitario="1000"
_json_data.detalle[1].descuentoPorcentaje="0.0"
_json_data.detalle[1].nomItem="Prueba de factura"
_json_data.detalle[1].uniMed="N/A"
_json_data.detalle[1].cantidad="1"
_json_data.detalle[1].montoDescuento="0.00"
_json_data.detalle[1].indFact="2"
_json_data.detalle[1].montoItem="1000"

_json_data.detalle[2].nroLinDet="2"
_json_data.detalle[2].precioUnitario="1000"
_json_data.detalle[2].descuentoPorcentaje="0.0"
_json_data.detalle[2].nomItem="otro renglon"
_json_data.detalle[2].uniMed="N/A"
_json_data.detalle[2].cantidad="1"
_json_data.detalle[2].montoDescuento="0.00"
_json_data.detalle[2].indFact="2"
_json_data.detalle[2].montoItem="1000"

Info(VariantToJSON(_json_data))