Duda Plugin JSon

Aquí puedes preguntar o compartir tus dudas y conocimientos acerca del programa
Que tal gente hoy tengo una duda con el uso del plugin action JSon el como exportar el contenido de una grid usando el plugin JSon para que quede en ese formato y pueda ser leído por otras aplicaciones

dejo el ejemplo del plugin :

Código: Seleccionar todo

https://www.mediafire.com/file/qrwpo4h97xtpnt9/JSON+Action+Plugin.apz/file
y dejo el plugin:

Código: Seleccionar todo

https://www.mediafire.com/file/qrwpo4h97xtpnt9/JSON_Action_Plugin.apz/file
last year i just started using json plugin for study purpose.. and i found it works will..

i used this https://github.com/rxi/json.lua

using json.encode you can write your json data..

it works with other application also..

cheers..
Thank you very much for the info but I remain the same with the doubt of how instead of using a table already given to export, take the data from a grid to be able to export
Agotaras123 escribió:
06 Feb 2021 18:01
Thank you very much for the info but I remain the same with the doubt of how instead of using a table already given to export, take the data from a grid to be able to export
Olá Colega :friends:
voê ja fez dessa forma ?
tSelected = SQLite.QueryToTable(db, "SELECT * FROM 
tSelected = JSON.Decode(JSON.Encode(tSelected))
for nRow = 1, tSelected.Rows do
Grid.SetCellText("Grid1", nLine, 0, tSelected.Data[nRow] ["RecordID"], false); 
Grid.SetCellText("Grid1", nLine, 1, tSelected.Data[nRow]     ["TIPO"], false);
Grid.SetCellText("Grid1", nLine, 2, tSelected.Data[nRow]["CATEGORIA"], false);
end
hi Agotaras123 i haven't used this plugin yet but this is the source code for it :
HIDE: ON
Hidebb Message Hidden Description
dripro escribió:
06 Feb 2021 20:14
Agotaras123 escribió:
06 Feb 2021 18:01
Thank you very much for the info but I remain the same with the doubt of how instead of using a table already given to export, take the data from a grid to be able to export
Olá Colega :friends:
voê ja fez dessa forma ?
tSelected = SQLite.QueryToTable(db, "SELECT * FROM 
tSelected = JSON.Decode(JSON.Encode(tSelected))
for nRow = 1, tSelected.Rows do
Grid.SetCellText("Grid1", nLine, 0, tSelected.Data[nRow] ["RecordID"], false); 
Grid.SetCellText("Grid1", nLine, 1, tSelected.Data[nRow]     ["TIPO"], false);
Grid.SetCellText("Grid1", nLine, 2, tSelected.Data[nRow]["CATEGORIA"], false);
end

Que tal Dripo intentare esto solo que uso MySQL veré como adaptarlo y te cuento.
abood1987 escribió:
06 Feb 2021 22:36
hi Agotaras123 i haven't used this plugin yet but this is the source code for it :
Hola abood1987 Revisare tu codigo a ver si logro entender jajajaj y usarlo, muchas gracias.
The problem is very simple, it is related to the correct understanding of dealing with arrays, and here the plugin codes were dealing with the array .
tengo este codigo y no me funciona
json = require "json"


MySQLCursor = MySQLConnection:execute("SELECT * FROM demo.declaraciones where formulario = '3259331'")
for i = 1, MySQLCursor:numrows() do
local id_registro,formulario,id_regimen,id_aduana_declaracion,anio,correlativo,fecha_aceptacion,id_agente,rtn,nom_consignatario,nom_proveedor,direccion,id_origen,id_procedencia,id_medio,id_transportista,nom_transportista,id_destino,facturas,cant_facturas,placa_cabezal,marchamo_origen,id_cabezal,no_contenedor,id_contenedor,manifiesto,no_declaracion,id_aduana_entrada,id_aduana_salida,fecha_cancelacion,ubicacion,marcas,tasa,fob,flete,seguro,otros,cif_total,ajustes,cif_imponible,no_garantia,tipo_garantia,monto_garantia,fecha_garantia,observaciones,fecha_declarante,contraescritura,tipo,marchamo_aduana,bl,impreso,factura_contable,id_exento,fianza,tasa_otro,tipo_otra,fecha_aduana_entrada,fecha_aduana_salida,procedencia,chkProcedencia,deposito,codigo_embalaje,codigo_fpago,id_incoterms,cant_bultos,peso_bbultos,divisa_flete,divisa_seguro,divisa_factura,total_almacenaje,motivo_susp,dep_almacenamiento,deposito_dest,porc_interes_fact,plazo,cant_items,docDestProv,entFinancieraMed,aduanaTransitoDest,depositoTransitoDest,rutaTransito,estado_transaccion,Num_transaccion,id_sarah,canal_solicitado,fob_otra,cancela_global,cantidad_comercial,ejes,id_manifiesto_entregaRapida,expediente,estado_declaracion,llavehabilitar,fecha_creacion,id_modalidad = MySQLCursor:fetch();
	tSelected = JSON.Encode(formulario)
	Input.SetText("Input1", tSelected)
end
este me funciona pero por columna y ocupo tomar todos los datos de ese item en la base de datos.





tengo este otro y tampoco me funciona
function rows (connection, sql_statement)
   local cursor = assert(connection:execute (sql_statement))
   return function ()
        return cursor:fetch()
    end
end

local s = "";
for id_registro,formulario,id_regimen,id_aduana_declaracion,anio,correlativo,fecha_aceptacion,id_agente,rtn,nom_consignatario,nom_proveedor,direccion,id_origen,id_procedencia,id_medio,id_transportista,nom_transportista,id_destino,facturas,cant_facturas,placa_cabezal,marchamo_origen,id_cabezal,no_contenedor,id_contenedor,manifiesto,no_declaracion,id_aduana_entrada,id_aduana_salida,fecha_cancelacion,ubicacion,marcas,tasa,fob,flete,seguro,otros,cif_total,ajustes,cif_imponible,no_garantia,tipo_garantia,monto_garantia,fecha_garantia,observaciones,fecha_declarante,contraescritura,tipo,marchamo_aduana,bl,impreso,factura_contable,id_exento,fianza,tasa_otro,tipo_otra,fecha_aduana_entrada,fecha_aduana_salida,procedencia,chkProcedencia,deposito,codigo_embalaje,codigo_fpago,id_incoterms,cant_bultos,peso_bbultos,divisa_flete,divisa_seguro,divisa_factura,total_almacenaje,motivo_susp,dep_almacenamiento,deposito_dest,porc_interes_fact,plazo,cant_items,docDestProv,entFinancieraMed,aduanaTransitoDest,depositoTransitoDest,rutaTransito,estado_transaccion,Num_transaccion,id_sarah,canal_solicitado,fob_otra,cancela_global,cantidad_comercial,ejes,id_manifiesto_entregaRapida,expediente,estado_declaracion,llavehabilitar,fecha_creacion,id_modalidad in rows(MySQLConnection, "SELECT  id_registro,formulario,id_regimen,id_aduana_declaracion,anio,correlativo,fecha_aceptacion,id_agente,rtn,nom_consignatario,nom_proveedor,direccion,id_origen,id_procedencia,id_medio,id_transportista,nom_transportista,id_destino,facturas,cant_facturas,placa_cabezal,marchamo_origen,id_cabezal,no_contenedor,id_contenedor,manifiesto,no_declaracion,id_aduana_entrada,id_aduana_salida,fecha_cancelacion,ubicacion,marcas,tasa,fob,flete,seguro,otros,cif_total,ajustes,cif_imponible,no_garantia,tipo_garantia,monto_garantia,fecha_garantia,observaciones,fecha_declarante,contraescritura,tipo,marchamo_aduana,bl,impreso,factura_contable,id_exento,fianza,tasa_otro,tipo_otra,fecha_aduana_entrada,fecha_aduana_salida,procedencia,chkProcedencia,deposito,codigo_embalaje,codigo_fpago,id_incoterms,cant_bultos,peso_bbultos,divisa_flete,divisa_seguro,divisa_factura,total_almacenaje,motivo_susp,dep_almacenamiento,deposito_dest,porc_interes_fact,plazo,cant_items,docDestProv,entFinancieraMed,aduanaTransitoDest,depositoTransitoDest,rutaTransito,estado_transaccion,Num_transaccion,id_sarah,canal_solicitado,fob_otra,cancela_global,cantidad_comercial,ejes,id_manifiesto_entregaRapida,expediente,estado_declaracion,llavehabilitar,fecha_creacion,id_modalidad From demo.declaraciones where formulario = '3259331'") do
	s = s .. string.format("%s", formulario);
	tSelected = JSON.Encode(s)
end

Input.SetText("InpFacInicial", tSelected)
el archivo como lo pretendo dejar es como se los muestro a continuación


Código: Seleccionar todo

{
  "declaracion":{
    "general":{
      "rucEmpresa":"",
      "cotizacionUSD":""
    },
    "aduana":{
      "idAduanaIngreso":"0004",
      "idAduanaDespacho":"0004",
      "idDeclaracion":"",
      "fechaAceptDecla":"2021-02-03"
    },
    "importador":{
      "nomImportador":"SUPER TECHNOLOGIES",
      "rtnImportador":"0801-9998-4030",
      "numRegImportador":"08019998470",
      "dirImportador":"FLORENCIA SUR CALLE PRINCIPAL 2",
      "ciuImportador":"TEGUCIGALPA",
      "paisImportador":"HN",
      "telImportador":"22324",
      "faxImportador":"22217",
      "emailImportador":"[email protected]",
      "nivComImportador":"DIS",
      "otrNivComImportador":"N\/A"
    },
    "proveedor":{
      "idProveedor":"SUPER TECHNOLOGIES.",
      "nombre":"SUPER TECHNOLOGIES",
      "direccion":"2200 NW 102ND AVENUE, BAY #6 , FL 33172",
      "ciudad":"MIAMI",
      "pais":"US",
      "telefono":"305-594-2200",
      "fax":"NO TIENE",
      "email":"[email protected]",
      "condComercial":"DT",
      "otraCondicion":"N\/A"
    },
    "intermediario":{
      "nomIntermediario":"",
      "dirIntermediario":"",
      "ciuIntermediario":"",
      "paisIntermediario":"",
      "telIntermediario":"",
      "faxIntermediario":"",
      "emailIntermediario":"",
      "tipoIntermediario":"",
      "otroIntermediario":""
    },
    "transaccion":{
      "lugarEntrega":"MIAMI",
      "paisEntrega":"US",
      "condicionEntrega":"FOB",
      "versionCondicionEntrega":"2020",
      "numContrato":"",
      "fechaContrato":"",
      "formaEnvio":"TT",
      "otrFormaEnvio":"N\/A",
      "indPagoEfectuado":"N",
      "formaPago":"TB",
      "otraFormaPago":"N\/A",
      "lugarEmbarque":"USMIA",
      "paisEmbarque":"US",
      "paisExportacion":"US",
      "fechaExportacion":"2021-01-21",
      "monedaTransaccion":"USD",
      "tipoCambioMonedaTrans":""
    },
    "condiciones":{
      "restricciones":"N",
      "descRestricciones":"",
      "contraPrestacion":"N",
      "descContraPrestacion":"",
      "ventaCondicionada":"N",
      "vinculacionCompVend":"N",
      "tipoVinculacion":"",
      "vincInfluenciaPrecio":"N",
      "pagoDescuentos":"N",
      "conceptoPorPagosDesc":"",
      "existenCanones":"N",
      "razonPago":"",
      "resolAdministrativa":"",
      "fechaResolucion":"",
      "numeroCasillaResol":""
    },
    "determinacion":{
      "importeFactura":"4,690.74",
      "montoPagosInd":"0.00",
      "importeContraprestacion":"0.00",
      "importeReversion":"0.00",
      "gastosComisiones":"0.00",
      "gastosEmbalajes":"0.00",
      "valorMaterialesIncorporados":"0.00",
      "valorHerramientasProd":"0.00",
      "valorMaterialesConsumidos":"0.00",
      "valorIngenieriaExt":"0.00",
      "valorDerLicencia":"0.00",
      "importeTransporte":"512.00",
      "importeCargaManipulacion":"0.00",
      "importeSeguro":"70.36",
      "importeAsistenciaTecnica":"0.00",
      "importeTransportePuerto":"0.00",
      "importeImpuestos":"0.00",
      "importeIntereses":"0.00",
      "importeOtrasDeducciones":"0.00",
      "importeRealPagado":"4,690.74",
      "importeAjustes":"582.36",
      "totalDeducciones":"0.00",
      "valorAduana":"5,273.10"
    },
    "facturas":[
      {
        "informacion":{
          "nroFactura":"987654",
          "fecha":"2020-12-14",
          "totalFlete":"0.00",
          "totalSeguro":"0.00",
          "indProrrateo":false
        },
        "items":[
          {
            "nroItem":"1",
            "cantComercial":"15",
            "uniComercial":"18",
            "designacionComercial":"IMPRESORAS ",
            "caracteristicasMercancias":"MULTIFUNCIONALES",
            "marcaMercancias":"CANON",
            "modeloMercancias":"PTRCANE402",
            "estadoMercancias":"NU",
            "paisOriMercancias":"VN",
            "posArancelaria":"8443.31.00.00.00",
            "precioUnitario":"24.1500",
            "totalFobUnitario":"362.2500",
            "importeFlete":"0.00",
            "importeSeguro":"0.00",
            "importeOtrosGastos":"0.00",
            "errors":{}
          },
          {
            "nroItem":"2",
            "cantComercial":"35",
            "uniComercial":"18",
            "designacionComercial":"IMPRESORAS ",
            "caracteristicasMercancias":"MULTIFUNCIONALES",
            "marcaMercancias":"CANON",
            "modeloMercancias":"PTRCAN301",
            "estadoMercancias":"NU",
            "paisOriMercancias":"VN",
            "posArancelaria":"8443.31.00.00.00",
            "precioUnitario":"35.0000",
            "totalFobUnitario":"1,225.0000",
            "importeFlete":"0.00",
            "importeSeguro":"0.00",
            "importeOtrosGastos":"0.00",
            "errors":{}
          },
          {
            "nroItem":"3",
            "cantComercial":"21",
            "uniComercial":"18",
            "designacionComercial":"IMPRESORAS ",
            "caracteristicasMercancias":"MULTIFUNCIONALES",
            "marcaMercancias":"CANON",
            "modeloMercancias":"PTRCANE471",
            "estadoMercancias":"NU",
            "paisOriMercancias":"VN",
            "posArancelaria":"8443.31.00.00.00",
            "precioUnitario":"37.4400",
            "totalFobUnitario":"786.2400",
            "importeFlete":"0.00",
            "importeSeguro":"0.00",
            "importeOtrosGastos":"0.00",
            "errors":{}
          },
          {
            "nroItem":"4",
            "cantComercial":"15",
            "uniComercial":"18",
            "designacionComercial":"IMPRESORAS ",
            "caracteristicasMercancias":"MULTIFUNCIONALES",
            "marcaMercancias":"CANON",
            "modeloMercancias":"PTRCAN6810",
            "estadoMercancias":"NU",
            "paisOriMercancias":"TH",
            "posArancelaria":"8443.31.00.00.00",
            "precioUnitario":"25.1500",
            "totalFobUnitario":"377.2500",
            "importeFlete":"0.00",
            "importeSeguro":"0.00",
            "importeOtrosGastos":"0.00",
            "errors":{}
          },
          {
            "nroItem":"5",
            "cantComercial":"40",
            "uniComercial":"18",
            "designacionComercial":"IMPRESORAS ",
            "caracteristicasMercancias":"MULTIFUNCIONALES",
            "marcaMercancias":"EPSON",
            "modeloMercancias":"PTRCANEPS310",
            "estadoMercancias":"NU",
            "paisOriMercancias":"TH",
            "posArancelaria":"8443.31.00.00.00",
            "precioUnitario":"15.5000",
            "totalFobUnitario":"620.0000",
            "importeFlete":"0.00",
            "importeSeguro":"0.00",
            "importeOtrosGastos":"0.00",
            "errors":{}
          },
          {
            "nroItem":"6",
            "cantComercial":"55",
            "uniComercial":"18",
            "designacionComercial":"IMPRESORAS ",
            "caracteristicasMercancias":"MULTIFUNCIONALES",
            "marcaMercancias":"CANON",
            "modeloMercancias":"PTRCAN2410",
            "estadoMercancias":"NU",
            "paisOriMercancias":"VN",
            "posArancelaria":"8443.31.00.00.00",
            "precioUnitario":"24.0000",
            "totalFobUnitario":"1,320.0000",
            "importeFlete":"0.00",
            "importeSeguro":"0.00",
            "importeOtrosGastos":"0.00",
            "errors":{}
          }
        ]
      }
    ]
  },
  "usuario_id":""
}
Tonight I'm going to look what happens :friends:
as abood says, use json.lua

https://github.com/rxi/json.lua/blob/master/json.lua

you can use json.encode and json.decode for convenience, it will turn tables into json and vice-versa

make sure you build a table with the correct formar to parse it and not use the sql returned tables as they has function keys on the tree, better build a table with the data you want and then convert it
Pabloko escribió:
09 Feb 2021 16:40
as abood says, use json.lua

https://github.com/rxi/json.lua/blob/master/json.lua

you can use json.encode and json.decode for convenience, it will turn tables into json and vice-versa

make sure you build a table with the correct formar to parse it and not use the sql returned tables as they has function keys on the tree, better build a table with the data you want and then convert it
eso me fije que de la consulta mysql me agrega caracteres de retorno \n \t realizare pruebas de como me dices a ver si lo logro hacer.
tenga algún ejemplo de apz para lo que está intentando hacer esta vez ?
Aqui dejo el apz de lo que quiero hacer solo que la parte de la grid no se como cargarla a la tabla tampoco


Código: Seleccionar todo

http://www.mediafire.com/file/d2mofjxy3yp7ft2/json.apz/file
yes ok just used :


https://www.indigorose.com/webhelp/ams7 ... ToFile.htm
https://www.indigorose.com/webhelp/ams7 ... omFile.htm

if you want a complete example of data saving and recovery I can write it for you :friends:
abood1987 escribió:
16 Feb 2021 00:07
yes ok just used :


https://www.indigorose.com/webhelp/ams7 ... ToFile.htm
https://www.indigorose.com/webhelp/ams7 ... omFile.htm

if you want a complete example of data saving and recovery I can write it for you :friends:
te agradecería tu ayuda con ello.
Agotaras123 escribió:
05 Feb 2021 19:31
y pueda ser leído por otras aplicaciones
Do you mean a specific file you want to read or what do you mean?
Or do you want to save the Grid data in any database?
Sorry for the late reply :friends:

Some thing like that ? :
result = Grid.SaveToFile("GridItems", "AutoPlay\\Docs\\Grid_data.txt", ",");
result = TextFile.ReadToString("AutoPlay\\Docs\\Grid_data.txt");
Input.SetText("Input1", result);
and if you want to load again in to Grid :
 Grid.LoadFromFile("GridItems", "AutoPlay\\Docs\\Grid_data.txt", ",", true);
No lo que quiero es guardar en json lo que contiene ya mi grid junto a lo que tengo en los de mas objetos pero eso ya lo tengo claro lo que no logro hacer es obtener también el texto de la grid estos datos seran variantes como puede ser solo 1 item o 1000 item
Podrias mostrar un ejemplo de tu grid? Para entender eso de las variables que dices.