« JSON » : différence entre les versions
Apparence
Ligne 36 : | Ligne 36 : | ||
* XPath for JSON | * XPath for JSON | ||
* JSONPointer | * JSONPointer | ||
<kode lang='js'> | |||
const result = JSONPath.JSONPath({ | |||
path: 'json query', | |||
json: myJsonObject | |||
}); | |||
</kode> | |||
== [https://support.smartbear.com/alertsite/docs/monitors/api/endpoint/jsonpath.html JSONPath syntax] == | == [https://support.smartbear.com/alertsite/docs/monitors/api/endpoint/jsonpath.html JSONPath syntax] == |
Dernière version du 17 février 2021 à 10:38
Liens
Définition
JavaScript Object Notation, tout comme XML, sert à sérialiser des données.
Structure
{
"nom": "valeur",
"nom2": {
"label1": "valeur",
"label2": "valeur"
},
"tableau": [
{
"nom1": "valeur",
"nom2": "valeur"
},
{
"nom1": "valeur",
"nom2": "valeur"
}
]
}
|
Query languages
- JSONPath Plus
- XPath for JSON
- JSONPointer
const result = JSONPath.JSONPath({
path: 'json query',
json: myJsonObject
});
|
JSONPath syntax
{
"A": "1",
"B": {
"X": "2"
},
"C": {
"X": "3"
},
"D": [
{
"Y": "4",
"Z": "44"
},
{
"Y": "5",
"Z": "55"
}
]
}
|
A
// [ "1" ]
B.X
// [ "2" ]
*.X
$..X
// [ "2", "3" ]
D[0]
// { "Y": "4", "Z": "44" }
D[*].Y
// [ "4", "5" ]
D[?(@.Y === "4")].Z
// [ "44" ]
|