Hi guys, I have the following problem when I try to consume Prestashop rest api.
and the Json answer is not complete
"total_discounts_tax_excl": "0.000000", "total_paid" ......
java.lang.RuntimeException: JSON Array expected.
B4X:
Dim j As HttpJob
j.Initialize("",Me)
j.Download("https://pasteleriastrindberg.cl/api/orders?display=full&limit=1&output_format=JSON&ws_key=secret")
Wait For (j) JobDone(j As HttpJob)
If j.Success Then
Dim jp As JSONParser
jp.Initialize(j.GetString2("UTF8"))
Dim quotes As List = jp.NextArray
For Each quot As Map In quotes
Next
End If
j.Release
the json itself contains a MAP. orders inside this map is a List.
B4X:
Dim parser As JSONParser
parser.Initialize(<text>)
Dim root As Map = parser.NextObject
Dim orders As List = root.Get("orders")
For Each colorders As Map In orders
Dim id_address_invoice As String = colorders.Get("id_address_invoice")
Dim gift As String = colorders.Get("gift")
Dim associations As Map = colorders.Get("associations")
Dim order_rows As List = associations.Get("order_rows")
For Each colorder_rows As Map In order_rows
Dim unit_price_tax_excl As String = colorder_rows.Get("unit_price_tax_excl")
Dim id_customization As String = colorder_rows.Get("id_customization")
Dim product_upc As String = colorder_rows.Get("product_upc")
Dim product_reference As String = colorder_rows.Get("product_reference")
Dim product_ean13 As String = colorder_rows.Get("product_ean13")
Dim product_price As String = colorder_rows.Get("product_price")
Dim product_name As String = colorder_rows.Get("product_name")
Dim product_quantity As String = colorder_rows.Get("product_quantity")
Dim unit_price_tax_incl As String = colorder_rows.Get("unit_price_tax_incl")
Dim product_isbn As String = colorder_rows.Get("product_isbn")
Dim product_id As String = colorder_rows.Get("product_id")
Dim product_attribute_id As String = colorder_rows.Get("product_attribute_id")
Dim id As String = colorder_rows.Get("id")
Next
Dim total_paid_tax_excl As String = colorders.Get("total_paid_tax_excl")
Dim total_wrapping_tax_incl As String = colorders.Get("total_wrapping_tax_incl")
Dim recyclable As String = colorders.Get("recyclable")
Dim id_customer As String = colorders.Get("id_customer")
Dim round_type As String = colorders.Get("round_type")
Dim invoice_date As String = colorders.Get("invoice_date")
Dim carrier_tax_rate As String = colorders.Get("carrier_tax_rate")
Dim valid As String = colorders.Get("valid")
Dim total_discounts As String = colorders.Get("total_discounts")
Dim reference As String = colorders.Get("reference")
Dim id_lang As String = colorders.Get("id_lang")
Dim mobile_theme As String = colorders.Get("mobile_theme")
Dim total_wrapping_tax_excl As String = colorders.Get("total_wrapping_tax_excl")
Dim total_paid As String = colorders.Get("total_paid")
Dim total_shipping_tax_incl As String = colorders.Get("total_shipping_tax_incl")
Dim secure_key As String = colorders.Get("secure_key")
Dim total_products_wt As String = colorders.Get("total_products_wt")
Dim total_shipping As String = colorders.Get("total_shipping")
Dim id_shop As String = colorders.Get("id_shop")
Dim delivery_number As String = colorders.Get("delivery_number")
Dim payment As String = colorders.Get("payment")
Dim id As Int = colorders.Get("id")
Dim id_currency As String = colorders.Get("id_currency")
Dim invoice_number As String = colorders.Get("invoice_number")
Dim conversion_rate As String = colorders.Get("conversion_rate")
Dim id_carrier As String = colorders.Get("id_carrier")
Dim total_discounts_tax_incl As String = colorders.Get("total_discounts_tax_incl")
Dim module As String = colorders.Get("module")
Dim current_state As String = colorders.Get("current_state")
Dim id_address_delivery As String = colorders.Get("id_address_delivery")
Dim total_shipping_tax_excl As String = colorders.Get("total_shipping_tax_excl")
Dim shipping_number As String = colorders.Get("shipping_number")
Dim date_add As String = colorders.Get("date_add")
Dim total_paid_real As String = colorders.Get("total_paid_real")
Dim delivery_date As String = colorders.Get("delivery_date")
Dim total_paid_tax_incl As String = colorders.Get("total_paid_tax_incl")
Dim id_cart As String = colorders.Get("id_cart")
Dim date_upd As String = colorders.Get("date_upd")
Dim total_wrapping As String = colorders.Get("total_wrapping")
Dim total_products As String = colorders.Get("total_products")
Dim gift_message As String = colorders.Get("gift_message")
Dim round_mode As String = colorders.Get("round_mode")
Dim id_shop_group As String = colorders.Get("id_shop_group")
Dim total_discounts_tax_excl As String = colorders.Get("total_discounts_tax_excl")
Next
Dim parser As JSONParser parser.Initialize(<text>) Dim root As Map = parser.NextObject Dim orders As List = root.Get("orders") For Each colorders As Map In orders Dim id_address_invoice As String = colorders.Get("id_address_invoice") Dim gift As String = colorders.Get("gift") Dim associations As Map = colorders.Get("associations") Dim order_rows As List = associations.Get("order_rows") For Each colorder_rows As Map In order_rows Dim unit_price_tax_excl As String = colorder_rows.Get("unit_price_tax_excl") Dim id_customization As String = colorder_rows.Get("id_customization") Dim product_upc As String = colorder_rows.Get("product_upc") Dim product_reference As String = colorder_rows.Get("product_reference") Dim product_ean13 As String = colorder_rows.Get("product_ean13") Dim product_price As String = colorder_rows.Get("product_price") Dim product_name As String = colorder_rows.Get("product_name") Dim product_quantity As String = colorder_rows.Get("product_quantity") Dim unit_price_tax_incl As String = colorder_rows.Get("unit_price_tax_incl") Dim product_isbn As String = colorder_rows.Get("product_isbn") Dim product_id As String = colorder_rows.Get("product_id") Dim product_attribute_id As String = colorder_rows.Get("product_attribute_id") Dim id As String = colorder_rows.Get("id") Next Dim total_paid_tax_excl As String = colorders.Get("total_paid_tax_excl") Dim total_wrapping_tax_incl As String = colorders.Get("total_wrapping_tax_incl") Dim recyclable As String = colorders.Get("recyclable") Dim id_customer As String = colorders.Get("id_customer") Dim round_type As String = colorders.Get("round_type") Dim invoice_date As String = colorders.Get("invoice_date") Dim carrier_tax_rate As String = colorders.Get("carrier_tax_rate") Dim valid As String = colorders.Get("valid") Dim total_discounts As String = colorders.Get("total_discounts") Dim reference As String = colorders.Get("reference") Dim id_lang As String = colorders.Get("id_lang") Dim mobile_theme As String = colorders.Get("mobile_theme") Dim total_wrapping_tax_excl As String = colorders.Get("total_wrapping_tax_excl") Dim total_paid As String = colorders.Get("total_paid") Dim total_shipping_tax_incl As String = colorders.Get("total_shipping_tax_incl") Dim secure_key As String = colorders.Get("secure_key") Dim total_products_wt As String = colorders.Get("total_products_wt") Dim total_shipping As String = colorders.Get("total_shipping") Dim id_shop As String = colorders.Get("id_shop") Dim delivery_number As String = colorders.Get("delivery_number") Dim payment As String = colorders.Get("payment") Dim id As Int = colorders.Get("id") Dim id_currency As String = colorders.Get("id_currency") Dim invoice_number As String = colorders.Get("invoice_number") Dim conversion_rate As String = colorders.Get("conversion_rate") Dim id_carrier As String = colorders.Get("id_carrier") Dim total_discounts_tax_incl As String = colorders.Get("total_discounts_tax_incl") Dim module As String = colorders.Get("module") Dim current_state As String = colorders.Get("current_state") Dim id_address_delivery As String = colorders.Get("id_address_delivery") Dim total_shipping_tax_excl As String = colorders.Get("total_shipping_tax_excl") Dim shipping_number As String = colorders.Get("shipping_number") Dim date_add As String = colorders.Get("date_add") Dim total_paid_real As String = colorders.Get("total_paid_real") Dim delivery_date As String = colorders.Get("delivery_date") Dim total_paid_tax_incl As String = colorders.Get("total_paid_tax_incl") Dim id_cart As String = colorders.Get("id_cart") Dim date_upd As String = colorders.Get("date_upd") Dim total_wrapping As String = colorders.Get("total_wrapping") Dim total_products As String = colorders.Get("total_products") Dim gift_message As String = colorders.Get("gift_message") Dim round_mode As String = colorders.Get("round_mode") Dim id_shop_group As String = colorders.Get("id_shop_group") Dim total_discounts_tax_excl As String = colorders.Get("total_discounts_tax_excl") Next