Good night,
I am trying to obtain the values of the json that I indicate, but for some fields I do not get the result, such as: ns2:dProtConsLote or ns2:dCodRes
Where is my mistake. Do I have the group well defined?
I have the following json, which I read from a file:
{
"success": true,
"environment": "test",
"xml": []
"msg": {
"ns2:rResEnviLoteDe": {
"$": {
"xmlns:ns2": "http://ekuatia.set.gov.py/sifen/xsd"
},
"ns2:dFecProc": "2023-12-14T07:12:48-03:00",
"ns2:dCodRes": "0300",
"ns2:dMsgRes": "Lote recibido con éxito",
"ns2:dProtConsLote": "11453601354823256",
"ns2:dTpoProces": "0"
},
"id": "647695277"
}
}
the definition of the group
GJson Group
success STRING(5)
environment STRING(255),Name('environment')
qxml &QUEUE,Name('xml')
G2 Group,Name('msg')
G3 Group,Name('ns2:rResEnviLoteDe')
G4 Group,Name('$')
xmlns:ns2 STRING(255),Name('xmlns:ns2')
End
ns2:dFecProc STRING(255),Name('ns2:dFecProc')
ns2:dCodRes STRING(255),Name('ns2:dCodRes')
ns2:dMsgRes STRING(255),Name('ns2:dMsgRes')
ns2:dProtConsLote STRING(255),Name('ns2:dProtConsLote')
ns2:dTpoProces STRING(255),Name('ns2:dTpoProces')
End
id STRING(255),Name('id')
End
End
qxml QUEUE
Str STRING(20000)
END
my code
root &= jsonFactory.ParseFile('respuesta.json')
IF root &= NULL
!error
MESSAGE('Syntax error near: '& jsonFactory.GetError() &'|at position '& jsonFactory.GetErrorPosition())
RETURN
END
!see the resulting json
json::DebugInfo(root.ToString(TRUE)) !formatted outpur
!MESSAGE(root.ToString(TRUE)) !formatted outpur
GJson.qxml &= qxml
IF NOT jsonFactory.ToGroup(root.ToString(), GJson, FALSE, '[{{"name":"xml", "instance":'& INSTANCE(qxml, THREAD()) &'}]')
MESSAGE('error: ' & jsonFactory.GetError())
RETURN
END
MESSAGE('GJson.success: ' & CLIP(LEFT(GJson.success)) |
& '|id: ' & CLIP(LEFT(GJson.G2.id)) |
& '|environment: ' & CLIP(LEFT(GJson.environment)) |
& '|ns2:dCodRes: ' & CLIP(LEFT(GJson.G2.G3.ns2:dCodRes)) |
& '|ns2:dProtConsLote: ' & CLIP(LEFT(GJson.G2.G3.ns2:dProtConsLote)) |
& '|xmlns:ns2: ' & CLIP(LEFT(GJson.G2.G3.G4.xmlns:ns2)) |
& '|records xml: ' & CLIP(LEFT(records(qxml))) |
)
!dispose all cJSON objects at once
root.Delete()
thank you very much for your help