Hi Thomas,

This problem is a general one when working with quotes; see:

  'It is called "St. John's College"!'

One solution is to go with the XQuery 3.1 string constructor [1]

  ``[It is called "St. John's College"!]``

Cheers,
Christian


[1] http://docs.basex.org/wiki/XQuery_3.1#String_Constructor


On Thu, Aug 10, 2017 at 2:41 PM, Thomas Daly <letter...@daladi.com> wrote:
> 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
>
>

Reply via email to