Extraire json

Vous voulez de l'aide ? Postez ici :)
Post Reply
bicyclethemepkmn
Posts: 1
Joined: 16 Jun 2018, 09:44

Extraire json

Post by bicyclethemepkmn » 16 Jun 2018, 09:53

Alors voilà, j'ai un json que j'ai tiré de l'API de qwant qui se présente comme ça.

Code: Select all

{"status":"success","data":{"query":{"locale":"fr_fr","query":"actiona","offset":0},"cache":{"key":"71d18e8d95de3eaf606e46b994cb8381","created":1529138901,"expiration":604800,"status":"miss","age":0},"result":{"total":33,"items":[{"title":"<b>Actiona<\/b> \u2013 Automatiser des t\u00e2ches sous Windows et Linux ...","favicon":"\/\/s.qwant.com\/fav\/k\/o\/korben_info.ico","url":"https:\/\/korben.info\/actiona.html","source":"https:\/\/korben.info\/<b>actiona<\/b>.html","desc":"Et pour ne rien g\u00e2cher \u00e0 l\u2019affaire, <b>Actiona<\/b> est distribu\u00e9 sous licence libre. Pour t\u00e9l\u00e9charger <b>Actiona<\/b>, c\u2019est par ici.","_id":"7ac0b954c6e02cec102377e05ca12cc1","position":1}],"filters":{"freshness":{"label":"Freshness","name":"freshness","type":"dropdown","selected":"all","values":[{"value":"all","label":"All time","translate":true},{"value":"day","label":"Past 24 hours","translate":true},{"value":"week","label":"Past week","translate":true},{"value":"month","label":"Past month","translate":true}]}},"version":"B"}}}
et comme ça une fois parsé.

Code: Select all

{

    "status":"success",
    "data":{
        "query":{
            "locale":"fr_fr",
            "query":"actiona",
            "offset":0
        },
        "cache":{
            "key":"71d18e8d95de3eaf606e46b994cb8381",
            "created":1529138901,
            "expiration":604800,
            "status":"miss",
            "age":0
        },
        "result":{
            "total":33,
            "items":[
                {
                    "title":"<b>Actiona<\/b> \u2013 Automatiser des t\u00e2ches sous Windows et Linux ...",
                    "favicon":"\/\/s.qwant.com\/fav\/k\/o\/korben_info.ico",
                    "url":"https:\/\/korben.info\/actiona.html",
                    "source":"https:\/\/korben.info\/<b>actiona<\/b>.html",
                    "desc":"Et pour ne rien g\u00e2cher \u00e0 l\u2019affaire, <b>Actiona<\/b> est distribu\u00e9 sous licence libre. Pour t\u00e9l\u00e9charger <b>Actiona<\/b>, c\u2019est par ici.",
                    "_id":"7ac0b954c6e02cec102377e05ca12cc1",
                    "position":1
                }
            ],
            "filters":{
                "freshness":{
                    "label":"Freshness",
                    "name":"freshness",
                    "type":"dropdown",
                    "selected":"all",
                    "values":[
                        {
                            "value":"all",
                            "label":"All time",
                            "translate":true
                        },
                        {
                            "value":"day",
                            "label":"Past 24 hours",
                            "translate":true
                        },
                        {
                            "value":"week",
                            "label":"Past week",
                            "translate":true
                        },
                        {
                            "value":"month",
                            "label":"Past month",
                            "translate":true
                        }
                    ]
                }
            },
            "version":"B"
        }
    }

}
du coup j'aimerai récupérer avec du javascript l'URL mais je sais pas vraiment comment utiliser la fonction JSON.parse().

Donc si quelqu''un peut m'aider ce serait sympa Merci :)

Post Reply