Forum Discussion

marcelocastro's avatar
marcelocastro
New Contributor
6 years ago

create json struct - data rows

A data set (dataset source) that must be transformed into a json structure. How can this accomplish this using groovy or another tool? For each COD_DOC a JSON file with its associated items must be created. Below is the list of data and json structure to be created. Thank you

 

COMPANY

ID

EVENT

COD_DOC

COD_EMPRESA

CATEGORIA_DOC

TIPO_DOC

INDICA_TRANF

DATA_DOC

DOC_ANO

COD_FORN

COD_MOEDA

INICIO_VIGENCIA

TERMINO_VIGENCIA

VALOR_CONTRATO

MEMORY

MEMORYTYPE

COD_USER_PEDIDO

COD_BLOQ

DATA_DOC_ITEM

COD_MATERIAL

COD_CENTRO

COD_DEPOSITO

QTDE_DOC_ITEM

CONV_NUMER

CONV_DENON

PRECO_DOC

PRECO_UNID

VALOR_DOC

REMESSA_FINAL

ITEM_CATEGO

COD_CONTRATO

COD_CONTRATO_ITEM

TIPO_URG

4004

4506044787

purchase_document

4506044787

 

F

UB

T

20130219

2013

1736

BRL

0

0

0

X

H

C3ANTONIOTR

 

0

6061458

   

560

1

1

0

100

0

 

7

 

0

0

4004

4506298061

purchase_document

4506298061

 

F

ZB

 

20130529

2013

   

0

0

0

X

H

GPATRICIALV

 

0

     

4

0

0

0

0

0

 

0

 

0

0

4004

4506298061

purchase_document

4506298061

 

F

ZB

 

20130529

2013

   

0

0

0

X

H

GPATRICIALV

 

0

806181

   

200

1

1

0

0

0

 

0

 

0

0

4004

4506406355

purchase_document

4506406355

 

F

ZCD

 

20130710

2013

7048089

 

0

0

0

X

H

CADELMIRBF

 

0

     

1

1

1

0

0

0

 

0

 

0

0

4004

4506412758

purchase_document

4506412758

 

F

ZCD

 

20130712

2013

1052696

 

0

0

0

X

H

CMARCOSVSA

 

0

     

1

1

1

0

0

0

 

9

 

0

0

4004

4506427995

purchase_document

4506427995

 

F

UB

T

20130718

2013

   

0

0

0

X

H

C3LEANDRORS

 

0

6061458

   

560

1

1

0

0

0

 

7

 

0

0

4004

4506485214

purchase_document

4506485214

 

F

ZCD

 

20130809

2013

   

0

0

0

X

H

CDANIELLAJ

L

0

     

0

0

0

0

0

0

 

0

 

0

0

 

{

    "company": COD_EMPRESA,

    "id": COD_DOC,

    "event": "purchase_document",

    "cod_doc":,

    "cod_empresa":,

    "categoria_doc":,

    "tipo_doc":,

    "indica_tranf":,

    "data_doc":,

    "doc_ano":,

    "cod_forn":,

    "cod_moeda":,

    "inicio_vigencia":,

    "termino_vigencia":,

    "valor_contrato":,

    "memory":,

    "memorytype":,

    "cod_user_pedido":,

    "item": [

        {

            “cod_doc_item”:,

"cod_bloq":,

            "data_doc_item":,

            "cod_material":,

            "cod_centro":,

            "cod_deposito":,

            "qtde_doc_item":,

            "conv_numer": ,

            "conv_denon": ,

            "preco_doc":,

            "preco_unid": ,

            "valor_doc":,

            "remessa_final":,

            "item_catego": ,

            "cod_contrato": ,

            "cod_contrato_item": ,

            "tipo_urg":

        },

        {

            “cod_doc_item”:,

"cod_bloq":,

            "data_doc_item":,

            "cod_material":,

            "cod_centro":,

            "cod_deposito":,

            "qtde_doc_item":,

            "conv_numer": ,

            "conv_denon": ,

            "preco_doc":,

            "preco_unid": ,

            "valor_doc":,

            "remessa_final":,

             "item_catego": ,

            "cod_contrato": ,

            "cod_contrato_item": ,

            "tipo_urg":

        }

    ]

}

  • Hi Richie

    Thank you for your suggestion. I did the data conversion, but I did not find a way to group the items in a document.
    The answer I obtained was to convert each row of the table into a JSON structure, but what I need and am having difficulty is to group the item data of each document into a single JSON for each document.
    Thank you

     

  • richie's avatar
    richie
    Community Hero

    Hey marcelocastro 

     

    if you actually want to convert from .xlsx to .json in situ I can't help - but there's an online converter that might help - it converts from .csv to .json - I found it here

     

    I also found a youtube vid on using javascript to do the job - here

     

    Cheers,

     

    richie

    • marcelocastro's avatar
      marcelocastro
      New Contributor

      Hi Richie

      Thank you for your suggestion. I did the data conversion, but I did not find a way to group the items in a document.
      The answer I obtained was to convert each row of the table into a JSON structure, but what I need and am having difficulty is to group the item data of each document into a single JSON for each document.
      Thank you