R
R
rama_jecboom2021-04-16 15:09:26
JSON
rama_jecboom, 2021-04-16 15:09:26

How to make JSON Path(Regex)?

Good afternoon, I have such json, how can I make JSON Path (Regex) these lines:jmcs://jd-contents/Sun/Sun_ULTRA.webm

"__class": "ContentAuthorizationEntry",
  "duration": 300,
  "changelist": 544216,
  "urls": {
    "jmcs://jd-contents/Sun/Sun_ULTRA.webm": "https://jd-s3.akamaized.net/private/map/Sun/Sun_ULTRA.webm/9c28826a30e2df0709aa023f3011d2ab.webm?auth=exp=16179930733600~acl=/private/map/Sun/*~hmac=5132987c51a3bcda04d7ef516a0d52af97acc530b65a25a6c9af1e508f1f9b4a",
    "jmcs://jd-contents/Sun/Sun_ULTRA.hd.webm": "https://jd-s3.akamaized.net/private/map/Sun/Sun_ULTRA.hd.webm/97260f53fe23f52f4c686a300bde029a.webm?auth=exp=16179930733600~acl=/private/map/Sun/*~hmac=5132987c51a3bcda04d7ef516a0d52af97acc530b65a25a6c9af1e508f1f9b4a",
    "jmcs://jd-contents/Sun/Sun_MID.webm": "https://jd-s3.akamaized.net/private/map/Sun/Sun_MID.webm/ef11a8504be52f0b7ad5da81e0369bd0.webm?auth=exp=16179930733600~acl=/private/map/Sun/*~hmac=5132987c51a3bcda04d7ef516a0d52af97acc530b65a25a6c9af1e508f1f9b4a",
    "jmcs://jd-contents/Sun/Sun_MID.hd.webm": "https://jd-s3.akamaized.net/private/map/Sun/Sun_MID.hd.webm/785753ead2b132ac4c8d790e121d05b4.webm?auth=exp=16179930733600~acl=/private/map/Sun/*~hmac=5132987c51a3bcda04d7ef516a0d52af97acc530b65a25a6c9af1e508f1f9b4a",
    "jmcs://jd-contents/Sun/Sun_LOW.webm": "https://jd-s3.akamaized.net/private/map/Sun/Sun_LOW.webm/d2aeec3bf811bb6aafef47d5e32f40ea.webm?auth=exp=16179930733600~acl=/private/map/Sun/*~hmac=5132987c51a3bcda04d7ef516a0d52af97acc530b65a25a6c9af1e508f1f9b4a",
    "jmcs://jd-contents/Sun/Sun_LOW.hd.webm": "https://jd-s3.akamaized.net/private/map/Sun/Sun_LOW.hd.webm/92a7b4daf5210039c4c1ed28eb5c46fa.webm?auth=exp=16179930733600~acl=/private/map/Sun/*~hmac=5132987c51a3bcda04d7ef516a0d52af97acc530b65a25a6c9af1e508f1f9b4a",
    "jmcs://jd-contents/Sun/Sun_HIGH.webm": "https://jd-s3.akamaized.net/private/map/Sun/Sun_HIGH.webm/1ebad9ff271e965659b2e1b827e24da5.webm?auth=exp=16179930733600~acl=/private/map/Sun/*~hmac=5132987c51a3bcda04d7ef516a0d52af97acc530b65a25a6c9af1e508f1f9b4a",
    "jmcs://jd-contents/Sun/Sun_HIGH.hd.webm": "https://jd-s3.akamaized.net/private/map/Sun/Sun_HIGH.hd.webm/612af6eb9529e208a40242f33914ebab.webm?auth=exp=16179930733600~acl=/private/map/Sun/*~hmac=5132987c51a3bcda04d7ef516a0d52af97acc530b65a25a6c9af1e508f1f9b4a",
    "jmcs://jd-contents/Sun/Sun.ogg": "https://jd-s3.akamaized.net/private/map/Sun/Sun.ogg/912779afd750760452be587dc7527d0f.ogg?auth=exp=16179930733600~acl=/private/map/Sun/*~hmac=5132987c51a3bcda04d7ef516a0d52af97acc530b65a25a6c9af1e508f1f9b4a"
  }
}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
DENIS Kokorev, 2021-04-19
@shmaroder

https://regex101.com/r/hjzRdR/1/ - right?

$re = '/.*?(jmcs:.*?)".*/m';
$str = '"__class": "ContentAuthorizationEntry",
  "duration": 300,
  "changelist": 544216,
  "urls": {
    "jmcs://jd-contents/Sun/Sun_ULTRA.webm": "https://jd-s3.akamaized.net/private/map/Sun/Sun_ULTRA.webm/9c28826a30e2df0709aa023f3011d2ab.webm?auth=exp=16179930733600~acl=/private/map/Sun/*~hmac=5132987c51a3bcda04d7ef516a0d52af97acc530b65a25a6c9af1e508f1f9b4a",
    ..............
    "jmcs://jd-contents/Sun/Sun.ogg": "https://jd-s3.akamaized.net/private/map/Sun/Sun.ogg/912779afd750760452be587dc7527d0f.ogg?auth=exp=16179930733600~acl=/private/map/Sun/*~hmac=5132987c51a3bcda04d7ef516a0d52af97acc530b65a25a6c9af1e508f1f9b4a"
  }
}';
$subst = '$1';
$result = preg_replace($re, $subst, $str);
echo "The result of the substitution is ".$result;

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question