Chiedo Aiuto per piccola App con lettura url webservice prestashop 1.7 json

Ciao a tutti, sto cercando di realizzare una piccola app con app inventor con cui leggere delle informazioni tramite il web service di prestashop 1.7 con json.
L'app magazzino cerca il prodotto con il codice di riferimento come questo esempio di query
( https://www.romanademolizioni.it/api/products/?filter[reference]=1626427662868&output_format=JSON ) la risposta è composta così: {"products":[{"id":37651}]}
dopo aver trovato dal codice riferimento il codice id prodotto dovrebbe partire in automatico subito un'altra query così composta ( https://www.romanademolizioni.it/api/products/37651&output_format=JSON )
questa è la risposta:

{"product":{"id":37651,"id_manufacturer":"23","id_supplier":"0","id_category_default":"1333","new":null,"cache_default_attribute":"0","id_default_image":"43901","id_default_combination":0,"id_tax_rules_group":"9","position_in_category":"184","manufacturer_name":"FIAT","quantity":"0","type":"simple","id_shop_default":"1","reference":"1626427662868","supplier_reference":"","location":"O1PPA2T4P2","width":"0.000000","height":"0.000000","depth":"0.000000","weight":"0.000000","quantity_discount":"0","ean13":"1626427662868","isbn":"","upc":"","cache_is_pack":"0","cache_has_attachments":"0","is_virtual":"0","state":"1","additional_delivery_times":"1","delivery_in_stock":"","delivery_out_stock":"","on_sale":"0","online_only":"0","ecotax":"0.000000","minimal_quantity":"1","low_stock_threshold":null,"low_stock_alert":"0","price":"100.000000","wholesale_price":"0.000000","unity":"","unit_price_ratio":"0.000000","additional_shipping_cost":"0.00","customizable":"0","text_fields":"0","uploadable_files":"0","active":"1","redirect_type":"301-category","id_type_redirected":"0","available_for_order":"1","available_date":"0000-00-00","show_condition":"0","condition":"used","show_price":"1","indexed":"1","visibility":"both","advanced_stock_management":"0","date_add":"2021-07-16 09:24:57","date_upd":"2021-09-13 23:20:56","pack_stock_type":"3","meta_description":"Cofano anteriore Fiat Multipla II Dal 2004 al 2010 1626427662868 FIATCofano anteriore Fiat Multipla II Dal 2004 al 2010 ","meta_keywords":"cofano, anteriore, fiat, multipla, dal, 2004, 2010, 1626427662868, 2010fiat","meta_title":"Cofano anteriore Fiat Multipla II Dal 2004 al 2010FIAT 1626427662868","link_rewrite":"cofano-anteriore-fiat-multipla-ii-dal-2004-al-2010-1626427662868","name":"Cofano anteriore Fiat Multipla II Dal 2004 al 2010","description":"<h1 style="text-align:center;">Cofano anteriore</h1>\n<h1 style="text-align:center;">Fiat Multipla II</h1>\n<h1 style="text-align:center;">Dal 2004 al 2010</h1>\n<h1 style="text-align:center;"> </h1>","description_short":"","available_now":"","available_later":"","associations":{"categories":[{"id":"2"},{"id":"38"},{"id":"1173"},{"id":"1333"}],"images":[{"id":"43901"},{"id":"43902"},{"id":"43904"},{"id":"43906"},{"id":"43908"}],"tags":[{"id":"14"},{"id":"22"},{"id":"35"},{"id":"52"},{"id":"59"},{"id":"60"},{"id":"105"},{"id":"29782"},{"id":"43944"}],"stock_availables":[{"id":"16979","id_product_attribute":"0"}]}}}

da questi dati io devo visualizzare sull'app i seguenti dati: id , name, reference , ean13 , location (sarebbe la posizione scaffale nel magazzino) e quantità, ci sto provando da un bel po ma nulla non ci riesco. Vi chiedo aiuto per favore...

allego immagine blocchi che avevo provato a inserire ed esempio app.

1 Like

For some reason it is not possible for me to decode the json you provide using AppInventor. Maybe someone else can decode.....

Agree with Tim. I tested the json using https://jsonlint.com/ , an online json evaluator . It indicates problems with lines 68...76

once I removed them the json will load however after it loads, I still was not able to parse the data from the json. :cry:

jsonError

1 Like

Ah, all of the text (html) in the value on line 68 contains quotes that need escaping \" to make the json work. After that is done return the value for the key product then get the keys and values.

How you do this (escape all the quotes) programatically, I do not know...

se invece del json usassi xml che è di base?

il primo url sarebbe:
https://www.romanademolizioni.it/api/products/?filter[reference]=1626427662868

è la risposta in xml sarebbe così composta:

<prestashop xmlns:xlink="http://www.w3.org/1999/xlink">
<products>
<product id="37651" xlink:href="https://www.romanademolizioni.it/api/products/37651"/>
</products>
</prestashop>

dopo aver trovato dal codice riferimento il codice id prodotto dovrebbe partire in automatico subito un'altra query così:

https://www.romanademolizioni.it/api/products/37651

è la risposta in xml sarebbe così composta:

<prestashop xmlns:xlink="http://www.w3.org/1999/xlink">
<product>
<id>
<![CDATA[ 37651 ]]>
</id>
<id_manufacturer xlink:href="https://www.romanademolizioni.it/api/manufacturers/23">
<![CDATA[ 23 ]]>
</id_manufacturer>
<id_supplier>
<![CDATA[ 0 ]]>
</id_supplier>
<id_category_default xlink:href="https://www.romanademolizioni.it/api/categories/1333">
<![CDATA[ 1333 ]]>
</id_category_default>
<new/>
<cache_default_attribute>
<![CDATA[ 0 ]]>
</cache_default_attribute>
<id_default_image xlink:href="https://www.romanademolizioni.it/api/images/products/37651/43901" notFilterable="true">
<![CDATA[ 43901 ]]>
</id_default_image>
<id_default_combination notFilterable="true"/>
<id_tax_rules_group xlink:href="https://www.romanademolizioni.it/api/tax_rule_groups/9">
<![CDATA[ 9 ]]>
</id_tax_rules_group>
<position_in_category notFilterable="true">
<![CDATA[ 184 ]]>
</position_in_category>
<manufacturer_name notFilterable="true">
<![CDATA[ FIAT ]]>
</manufacturer_name>
<quantity notFilterable="true">
<![CDATA[ 0 ]]>
</quantity>
<type notFilterable="true">
<![CDATA[ simple ]]>
</type>
<id_shop_default>
<![CDATA[ 1 ]]>
</id_shop_default>
<reference>
<![CDATA[ 1626427662868 ]]>
</reference>
<supplier_reference/>
<location>
<![CDATA[ O1PPA2T4P2 ]]>
</location>
<width>
<![CDATA[ 0.000000 ]]>
</width>
<height>
<![CDATA[ 0.000000 ]]>
</height>
<depth>
<![CDATA[ 0.000000 ]]>
</depth>
<weight>
<![CDATA[ 0.000000 ]]>
</weight>
<quantity_discount>
<![CDATA[ 0 ]]>
</quantity_discount>
<ean13>
<![CDATA[ 1626427662868 ]]>
</ean13>
<isbn/>
<upc/>
<cache_is_pack>
<![CDATA[ 0 ]]>
</cache_is_pack>
<cache_has_attachments>
<![CDATA[ 0 ]]>
</cache_has_attachments>
<is_virtual>
<![CDATA[ 0 ]]>
</is_virtual>
<state>
<![CDATA[ 1 ]]>
</state>
<additional_delivery_times>
<![CDATA[ 1 ]]>
</additional_delivery_times>
<delivery_in_stock>
<language id="2" xlink:href="https://www.romanademolizioni.it/api/languages/2">
<![CDATA[ ]]>
</language>
</delivery_in_stock>
<delivery_out_stock>
<language id="2" xlink:href="https://www.romanademolizioni.it/api/languages/2">
<![CDATA[ ]]>
</language>
</delivery_out_stock>
<on_sale>
<![CDATA[ 0 ]]>
</on_sale>
<online_only>
<![CDATA[ 0 ]]>
</online_only>
<ecotax>
<![CDATA[ 0.000000 ]]>
</ecotax>
<minimal_quantity>
<![CDATA[ 1 ]]>
</minimal_quantity>
<low_stock_threshold/>
<low_stock_alert>
<![CDATA[ 0 ]]>
</low_stock_alert>
<price>
<![CDATA[ 100.000000 ]]>
</price>
<wholesale_price>
<![CDATA[ 0.000000 ]]>
</wholesale_price>
<unity/>
<unit_price_ratio>
<![CDATA[ 0.000000 ]]>
</unit_price_ratio>
<additional_shipping_cost>
<![CDATA[ 0.00 ]]>
</additional_shipping_cost>
<customizable>
<![CDATA[ 0 ]]>
</customizable>
<text_fields>
<![CDATA[ 0 ]]>
</text_fields>
<uploadable_files>
<![CDATA[ 0 ]]>
</uploadable_files>
<active>
<![CDATA[ 1 ]]>
</active>
<redirect_type>
<![CDATA[ 301-category ]]>
</redirect_type>
<id_type_redirected>
<![CDATA[ 0 ]]>
</id_type_redirected>
<available_for_order>
<![CDATA[ 1 ]]>
</available_for_order>
<available_date>
<![CDATA[ 0000-00-00 ]]>
</available_date>
<show_condition>
<![CDATA[ 0 ]]>
</show_condition>
<condition>
<![CDATA[ used ]]>
</condition>
<show_price>
<![CDATA[ 1 ]]>
</show_price>
<indexed>
<![CDATA[ 1 ]]>
</indexed>
<visibility>
<![CDATA[ both ]]>
</visibility>
<advanced_stock_management>
<![CDATA[ 0 ]]>
</advanced_stock_management>
<date_add>
<![CDATA[ 2021-07-16 09:24:57 ]]>
</date_add>
<date_upd>
<![CDATA[ 2021-09-16 12:07:10 ]]>
</date_upd>
<pack_stock_type>
<![CDATA[ 3 ]]>
</pack_stock_type>
<meta_description>
<language id="2" xlink:href="https://www.romanademolizioni.it/api/languages/2">
<![CDATA[ Cofano anteriore Fiat Multipla II Dal 2004 al 2010    1626427662868 FIATCofano anteriore Fiat Multipla II Dal 2004 al 2010     ]]>
</language>
</meta_description>
<meta_keywords>
<language id="2" xlink:href="https://www.romanademolizioni.it/api/languages/2">
<![CDATA[ cofano, anteriore, fiat, multipla, dal, 2004, 2010, 1626427662868, 2010fiat ]]>
</language>
</meta_keywords>
<meta_title>
<language id="2" xlink:href="https://www.romanademolizioni.it/api/languages/2">
<![CDATA[ Cofano anteriore Fiat Multipla II Dal 2004 al 2010FIAT 1626427662868 ]]>
</language>
</meta_title>
<link_rewrite>
<language id="2" xlink:href="https://www.romanademolizioni.it/api/languages/2">
<![CDATA[ cofano-anteriore-fiat-multipla-ii-dal-2004-al-2010-1626427662868 ]]>
</language>
</link_rewrite>
<name>
<language id="2" xlink:href="https://www.romanademolizioni.it/api/languages/2">
<![CDATA[ Cofano anteriore Fiat Multipla II Dal 2004 al 2010 ]]>
</language>
</name>
<description>
<language id="2" xlink:href="https://www.romanademolizioni.it/api/languages/2">
<![CDATA[ <h1 style="text-align:center;">Cofano anteriore</h1> <h1 style="text-align:center;">Fiat Multipla II</h1> <h1 style="text-align:center;">Dal 2004 al 2010</h1> <h1 style="text-align:center;">   </h1> ]]>
</language>
</description>
<description_short>
<language id="2" xlink:href="https://www.romanademolizioni.it/api/languages/2">
<![CDATA[ ]]>
</language>
</description_short>
<available_now>
<language id="2" xlink:href="https://www.romanademolizioni.it/api/languages/2">
<![CDATA[ ]]>
</language>
</available_now>
<available_later>
<language id="2" xlink:href="https://www.romanademolizioni.it/api/languages/2">
<![CDATA[ ]]>
</language>
</available_later>
<associations>
<categories nodeType="category" api="categories">
<category xlink:href="https://www.romanademolizioni.it/api/categories/2">
<id>
<![CDATA[ 2 ]]>
</id>
</category>
<category xlink:href="https://www.romanademolizioni.it/api/categories/38">
<id>
<![CDATA[ 38 ]]>
</id>
</category>
<category xlink:href="https://www.romanademolizioni.it/api/categories/1173">
<id>
<![CDATA[ 1173 ]]>
</id>
</category>
<category xlink:href="https://www.romanademolizioni.it/api/categories/1333">
<id>
<![CDATA[ 1333 ]]>
</id>
</category>
</categories>
<images nodeType="image" api="images">
<image xlink:href="https://www.romanademolizioni.it/api/images/products/37651/43901">
<id>
<![CDATA[ 43901 ]]>
</id>
</image>
<image xlink:href="https://www.romanademolizioni.it/api/images/products/37651/43902">
<id>
<![CDATA[ 43902 ]]>
</id>
</image>
<image xlink:href="https://www.romanademolizioni.it/api/images/products/37651/43904">
<id>
<![CDATA[ 43904 ]]>
</id>
</image>
<image xlink:href="https://www.romanademolizioni.it/api/images/products/37651/43906">
<id>
<![CDATA[ 43906 ]]>
</id>
</image>
<image xlink:href="https://www.romanademolizioni.it/api/images/products/37651/43908">
<id>
<![CDATA[ 43908 ]]>
</id>
</image>
</images>
<combinations nodeType="combination" api="combinations"/>
<product_option_values nodeType="product_option_value" api="product_option_values"/>
<product_features nodeType="product_feature" api="product_features"/>
<tags nodeType="tag" api="tags">
<tag xlink:href="https://www.romanademolizioni.it/api/tags/14">
<id>
<![CDATA[ 14 ]]>
</id>
</tag>
<tag xlink:href="https://www.romanademolizioni.it/api/tags/22">
<id>
<![CDATA[ 22 ]]>
</id>
</tag>
<tag xlink:href="https://www.romanademolizioni.it/api/tags/35">
<id>
<![CDATA[ 35 ]]>
</id>
</tag>
<tag xlink:href="https://www.romanademolizioni.it/api/tags/52">
<id>
<![CDATA[ 52 ]]>
</id>
</tag>
<tag xlink:href="https://www.romanademolizioni.it/api/tags/59">
<id>
<![CDATA[ 59 ]]>
</id>
</tag>
<tag xlink:href="https://www.romanademolizioni.it/api/tags/60">
<id>
<![CDATA[ 60 ]]>
</id>
</tag>
<tag xlink:href="https://www.romanademolizioni.it/api/tags/105">
<id>
<![CDATA[ 105 ]]>
</id>
</tag>
<tag xlink:href="https://www.romanademolizioni.it/api/tags/29782">
<id>
<![CDATA[ 29782 ]]>
</id>
</tag>
<tag xlink:href="https://www.romanademolizioni.it/api/tags/43944">
<id>
<![CDATA[ 43944 ]]>
</id>
</tag>
</tags>
<stock_availables nodeType="stock_available" api="stock_availables">
<stock_available xlink:href="https://www.romanademolizioni.it/api/stock_availables/16979">
<id>
<![CDATA[ 16979 ]]>
</id>
<id_product_attribute>
<![CDATA[ 0 ]]>
</id_product_attribute>
</stock_available>
</stock_availables>
<accessories nodeType="product" api="products"/>
<product_bundle nodeType="product" api="products"/>
</associations>
</product>
</prestashop>

ci sono speranze per aiutarmi? grazie mille ancora

nessuno mi può aiutare? perfavore

Hi, as @SteveJG suggested you ,after delete some lines in Json , for me the code works fine with these blocks
Json

I used this extension for Json -> dictionaries :point_right:

edited my Mod - please do not share directly an extension unless you are the developer

This extension was created because Kodular doesn't have the specific block. No need to use an extension in MIT App Inventor just use

image

1 Like

Great, I forgot it. Thanks

1 Like