Hello Guys,
I'm working in a project that I have a json string, and I want to deserialize it. I did a lot o research, but I couldn't find what I need.
Right now, I can deserialize only simple json, but when it is a nested json I don't know how to proceed.
I'm using this function to deserialize -> FormJsonSerializer::deserializeObject(classNum(NmbPwbContract), jsonString);
After some research this is how far I got.
Json:
{
"ShipmentId": "ShipmentValue",
"Boxes": [
{
"BoxId": "Value",
"Weight": "Value",
"Items": [
{
"ItemId": "Value",
"Qty": "1"
},
{
"ItemId": "Value",
"Qty": "1"
}
]
},
{
"BoxId": "Value",
"Weight": "Value",
"Items": {
"ItemId": "Value",
"Qty": "1"
}
}
]
}
RootContract
[DataContractAttribute]
class RootContract
{
Shipment shipmentId
List boxes = new List(Types::Class);
[DataMemberAttribute('ShipmentId')]
public Shipment parmShipmentId(Shipment _shipmentId = shipmentId)
{
shipmentId = _shipmentId;
return shipmentId;
}
[
DataMemberAttribute('Boxes'),
AifCollectionTypeAttribute('_boxes', Types::Class, classStr(BoxesContract)),
AifCollectionTypeAttribute('return', Types::Class, classStr(BoxesContract))
]
public List parmBoxes(List _boxes = boxes)
{
boxes = _boxes;
return boxes;
}
}
BoxesContract
[DataContractAttribute]
class BoxesContract
{
str boxId
Weight weight;
[DataMemberAttribute('BoxId')]
public str parmBoxId(str _boxId = boxId)
{
boxId = _boxId;
return _boxId;
}
[DataMemberAttribute('Weight')]
public real parmWeight(real _weight = weight)
{
weight = _weight;
return _weight;
}
}
I can retrieve the shipmentid information, but the boxes return empty.
Any help? Thanks