Regarding the JSON module json::parse function, how do you
cope with single quotes within the JSON data?
I have tried escaping them with a backslash, but to no
avail. In this example I think it’s the single quote in “St. John’s
College” that is causing the problem:
XQUERY let $database := 'lk'
let $options := map { 'format': 'direct', 'escape': 'yes' }
let $j :=
json:parse('{"roles":["poet","cleric"],"institutions":["St
John's College","Cambridge
University"],"characterId":"595051204300","homes":["Cheapside","London","Dean
Prior","Devon"],"image":"robert_herrick.jpg","DOB":"1591-08-24","attributes":["People
educated at Merchant Taylors' School","Northwood","Alumni
of St John's College","Cambridge","Alumni of Trinity
Hall","Cambridge","English poets","People from
the City of London","People educated at Westminster
School","London","English male
poets"],"DOD":"1674-10-08","nationality":"British","givenName":"Robert","familyName":"Herrick"}',
$options)
return db:add($database, $j, 'characters/c_595051204300_Robert_Herrick.xml')
Stopped at ., 3/78:
[XPST0003] Expecting closing bracket: json:parse. at
/usr/local/lib/basex-api/src/main/perl/BaseXClient.pm line 58.
Many thanks,
Thomas