Closed Bertware closed 6 years ago
When requesting data in the json or json-ld format, URLs are escaped. This makes them invalid.
{ "@context":{ "delay":"http:\/\/semweb.mmlab.be\/ns\/rplod\/delay", "platform":"http:\/\/semweb.mmlab.be\/ns\/rplod\/platform", "scheduledDepartureTime":"http:\/\/semweb.mmlab.be\/ns\/rplod\/scheduledDepartureTime", "headsign":"http:\/\/vocab.org\/transit\/terms\/headsign", "routeLabel":"http:\/\/semweb.mmlab.be\/ns\/rplod\/routeLabel", "stop":{"@id":"http:\/\/semweb.mmlab.be\/ns\/rplod\/stop","@type":"@id"} }, "@graph":[ { "@id":"https:\/\/irail.be\/stations\/nmbs\/008892007\/departures\/2018022218024dcc175d90fd67f8d8ecfff88eb8143b", "delay":"480", "platform":"12", "canceled":"0", "scheduledDepartureTime":"2018-02-22T18:02:00+01:00", "stop":"https:\/\/irail.be\/stations\/NMBS\/008892007", "headsign":"Knokke","routeLabel":"IC 2838" }, ... ] }
For example http:\/\/semweb.mmlab.be\/ns\/rplod\/delay should be http://semweb.mmlab.be/ns/rplod/delay. This goes for all URLs.
http:\/\/semweb.mmlab.be\/ns\/rplod\/delay
http://semweb.mmlab.be/ns/rplod/delay
We should use the flag JSON_UNESCAPED_SLASHES when encoding json data. See also: https://stackoverflow.com/questions/10210338/json-encode-escaping-forward-slashes
JSON_UNESCAPED_SLASHES
Not a bug: doesn’t break anything and is spec compliant. Wouldn’t mind getting rid of the escapes though.
When requesting data in the json or json-ld format, URLs are escaped. This makes them invalid.
Actual output:
Expected output:
For example
http:\/\/semweb.mmlab.be\/ns\/rplod\/delay
should behttp://semweb.mmlab.be/ns/rplod/delay
. This goes for all URLs.Solution:
We should use the flag
JSON_UNESCAPED_SLASHES
when encoding json data. See also: https://stackoverflow.com/questions/10210338/json-encode-escaping-forward-slashes