I am having some issues using DeserializeJson as follows:
1. An embedded array creates a new element in the array (collection) above it and not as a collection in its own level. (bit confusing) See 'Attributes' in example below. It creates 2 elements in register_sale_products, 1 which just has the attribute element's values and a second which is correct.
2. An empty array [] creates an object with the parent's elements. See 'Register_sale_payments' (1st record set) in example.
3. If there is more than one record set in the Json, PassArrayJson gives you a loValue is not an object.
To test points 1 and 2 you will need to remove the second record set from the example below.
Any advise please.
Many Thanks
Rodney
{
"register_sales": [
{
"id": "c4e35708",
"customer_id": "cc52b3f3",
"customer_name": "Test1",
"customer": {
"id": "cc52b3f3",
"name": "Test1",
"contact": {}
},
"register_sale_products": [
{
"sku": "coffee-hot",
"name": "Coffee (Demo)",
"quantity": 1,
"attributes": [
{
"name": "line_note",
"value": ""
}
]
}
],
"totals": {
"total_tax": 0.37,
"total_price": 2.63
},
"register_sale_payments": []
},
{
"id": "c4e35709",
"customer_id": "cc52b3f4",
"customer_name": "Test2",
"customer": {
"id": "cc52b3f4",
"name": "Test2",
"contact": {}
},
"register_sale_products": [
{
"sku": "coffee-cold",
"name": "Coffee Cold (Demo)",
"quantity": 1,
"attributes": [
{
"name": "line_note",
"value": ""
}
]
}
],
"totals": {
"total_tax": 2.37,
"total_price": 10.63
},
"register_sale_payments": [
{
"name": "Cash",
"amount": -2.05
},
{
"name": "Card",
"amount": -10.05
}
]
}
]
}