Reputation: 29
I have this JSON part:
{
"destination_addresses":[
"8000 AA Zwolle, Nederland"
],
"origin_addresses":[
"8100 AA Heino, Nederland"
],
"rows":[
{
"elements":[
{
"distance":{
"text":"14,6 km",
"value":14555
},
"duration":{
"text":"17 min.",
"value":1022
},
"status":"OK"
}
]
}
],
"status":"OK"
}
I want the regex to find the value 14555 and the value 1022 but not by searching for this numbers (because the numbers always change) but by searching by the node (value in distance and value in duration)
Any ideas?
Upvotes: 1
Views: 318
Reputation: 329
"distance" : {.*"value" : ([0-9]+) (,.*)*}
Do you mean something like this? If you really need a RegExp to do this.
I don't know the language you use. But in most languages, you can just parse the JSON to an object. Then you can get that easily.
For example, in JavaScript, var obj = JSON.parse(str);
may fit your demand.
Upvotes: 1