Hello everyone !!!
I need to generate the following json:
[{
"id": "A001",
"codigoAlternativo": "A001",
"unidadMedida": "Unidad",
"descripcion": "Galletita",
"idDepartamento": 1,
"atributos": ["Envase" , "Pesable" ],
"precio": 12.23,
"idIVA": 1,
"idIVADiferencial": 0,
"impuestoInterno": 0,
"valorUsuario1": "",
"valorUsuario2": "",
"cantidadPresentacion": 1,
"unidadesPresentacion": "Unidad",
"frentes": 1
}
]
The problem I have is in the “atributos” array that generates it like this:
"atributos": [{
"NAME": "Envase"
}, {
"NAME": "Pesable"
}
]
the complete json:
[{
"id": "A001",
"codigoAlternativo": "A001",
"unidadMedida": "Unidad",
"descripcion": "Alfajor",
"idDepartamento": 1,
"atributos": [{
"NAME": "Envase"
}, {
"NAME": "Pesable"
}
],
"precio": 12.23,
"idIVA": 1,
"idIVADiferencial": 0,
"impuestoInterno": 0,
"valorUsuario1": "",
"valorUsuario2": "",
"cantidadPresentacion": 1,
"unidadesPresentacion": "Unidad",
"frentes": 1
}
]
How is it resolved?
thank you so much
Below my code:
DATA
QatributosType QUEUE, TYPE
name STRING(50)
END
Qplu QUEUE
id STRING(30),NAME('id')
codigoAlternativo STRING(30),NAME('codigoAlternativo')
unidadMedida STRING(30),NAME('unidadMedida')
descripcion STRING(30),NAME('descripcion')
idDepartamento LONG,NAME('idDepartamento')
atributosQueue &QatributosType,NAME('atributos')
atributosQueueInstance LONG
precio REAL,NAME('precio')
idIVA LONG,NAME('idIVA')
idIVADiferencial LONG,NAME('idIVADiferencial')
impuestoInterno REAL,NAME('impuestoInterno')
valorUsuario1 STRING(30),NAME('valorUsuario1')
valorUsuario2 STRING(30),NAME('valorUsuario2')
cantidadPresentacion REAL,NAME('cantidadPresentacion')
unidadesPresentacion STRING(30),NAME('unidadesPresentacion')
frentes LONG,NAME('frentes')
END
CODE
CLEAR(Qplu)
Qplu.id = 'A001'
Qplu.codigoAlternativo = 'A001'
Qplu.unidadMedida = 'Unidad'
Qplu.descripcion = 'Alfajor'
Qplu.idDepartamento = 1
Qplu.precio = 12.23
Qplu.idIVA = 1
Qplu.idIVADiferencial = 0
Qplu.impuestoInterno = 0
Qplu.valorUsuario1 = ''
Qplu.valorUsuario2 = ''
Qplu.cantidadPresentacion = 1
Qplu.unidadesPresentacion = 'Unidad'
Qplu.frentes = 1
!- add atributos
Qplu.atributosQueue &= NEW QatributosType
Qplu.atributosQueueInstance = INSTANCE(Qplu.atributosQueue,THREAD())
CLEAR(Qplu.atributosQueue)
Qplu.atributosQueue.name = 'Envase'
ADD(Qplu.atributosQueue)
CLEAR(Qplu.atributosQueue)
Qplu.atributosQueue.name = 'Pesable'
ADD(Qplu.atributosQueue)
ADD(Qplu)
root &= json::CreateArray(Qplu,FALSE,'[{{"name":"atributos", "isQueue":true}]')
json::DebugInfo(root.ToString(TRUE))
SETCLIPBOARD(root.ToString(TRUE))