I want to know how to retrieve the information in Json.

Asked 2 years ago, Updated 2 years ago, 68 views

If I want to get the product_id number in products, get the name or main_image, and display it in Jquery, what kind of description do I need?Please let me know.

{
    "products": [
        {
            "product_id": "11",
            "product_code_min": "inf02",
            "product_code_max": "inf02",
            "name": "Influenza block throat candy blueberry flavor",
            "comment1": null,
            "comment2": null,
            "comment3": null,
            "main_list_comment": "<Miracle candy with swallow's nest>",
            "main_image": "11020721_56369067217cb.jpg",
            "main_list_image": "11020721_563690672a095.jpg",
            "main_large_image": "11020721_56369067196de.jpg",
            "price01_min": null,
            "price01_max": null,
            "price02_min": "2500",
            "price02_max": "2500",
            "stock_min": null,
            "stock_max": null,
            "stock_unlimited_min": "1",
            "stock_unlimited_max": "1",
            "deliv_date_id": "2",
            "status": "1",
            "del_flg": "0",
            "update_date": "2017-08-24 10:14:46",
            "price01_min_inctax": null,
            "price01_max_inctax": null,
            "price02_min_inctax"—2700,
            "price02_max_inctax"—2700,
            "price01_min_format": "0",
            "price01_max_format": "0",
            "price02_min_format": "2,500",
            "price02_max_format": "2,500",
            "price01_min_inctax_format": "0",
            "price01_max_inctax_format": "0",
            "price02_min_inctax_format": "2,700",
            "price02_max_inctax_format": "2,700",
            "price01_min_tax_format": "0",
            "price01_max_tax_format": "0",
            "price02_min_tax_format": "2,700",
            "price02_max_tax_format": "2,700",
            "papc2": {
                "value_id": "103",
                "product_id": "11",
                "column_id": "2",
                "value": "11181905_564c4d7b4000e.jpg",
                "name": "Thumbnail Image 01",
                "type": "image",
                "required": "0",
                "max_length"—Null
            },
            "papc3": {
                "value_id": "104",
                "product_id": "11",
                "column_id": "3",
                "value": "01271507_588ae396af94a.jpg",
                "name": "Thumbnail Image 02",
                "type": "image",
                "required": "0",
                "max_length"—Null
            },
            "papc4": {
                "value_id": "101",
                "product_id": "11",
                "column_id": "4",
                "value": "Tokyo",
                "name": "Country of Origin",
                "type": "text",
                "required": "0",
                "max_length": "50"
            },
            "papc5": {
                "value_id": "102",
                "product_id": "11",
                "column_id": "5",
                "value": "at room temperature",
                "name": "At room temperature, refrigeration, refrigeration",
                "type": "text",
                "required": "0",
                "max_length": "50"
            }
        }

jquery json

2022-09-30 21:34

1 Answers

If you would like to know the sample code that lists the contents of the products, would the following sample code be helpful?

<html>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <script src="https://code.jquery.com/jquery-3.3.1.min.js"></script>
    <script>
    function showProducts() {
        vardata = {
        "products": [
            {
                "product_id": "11",
                "name": "Influenza block throat candy blueberry flavor",
                "main_image": "11020721_56369067217cb.jpg",
                "papc2": {
                    "value_id": "103",
                    "product_id": "11" 
                }
            },
            {
               "product_id": "12",
               "name": "Tamiflu block throat candy with blackberry",
               "main_image": "11020721_56369067217cb.jpg",
               "papc2": {
                   "value_id": "104",
                   "product_id": "12" 
               }
            }
        ]}
        var products=data.products;
        for (vari in products) {
            $("#output").append("<li>"+products[i].product_id+":"+products[i].name+"<img src=\"+products[i].main_image+"\"/><li>";
        }
    }
    </script>
<body onload="showProducts()">
    <ulid="output"></ul>
</body>
</html>

If you are having trouble with other content such as "JSON in the questionnaire is incorrect", "JSON cannot be retrieved from an external URL", or "I can't display my own script as expected", as @Ooper pointed out, it would be easier to get a better answer.


2022-09-30 21:34

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.