From: Joe W. <jo...@gm...> - 2021-01-05 16:33:32
|
Hi Eduard, The eXist-specific JSON serialization you're seeing is described here: https://exist-db.org/exist/apps/wiki/blogs/eXist/JSONSerializer There's no mechanism for customizing this serialization, so your options are (a) use a badgerfish stylesheet, (b) transform your nodes into the intermediary format expected by the fn:xml-to-json() function, i.e., https://www.w3.org/TR/xpath-functions-31/#schema-for-json, or (c) transform your nodes into XDM maps/arrays and use the fn:serialize() function with the $options map { "method": "json" }. Joe On Tue, Jan 5, 2021 at 5:39 AM Eduard Drenth <ed...@fr...> wrote: > Yes, something like: > > "text":{"match":"De","#text":[" volgende ","match":"dag"," zat Esther in > ","match":"de"," bibliotheek achter een stapel boeken over psychiatrie en > psychopathologie.\n "]} > > or (using badgerfish xslt): > > "text":[{"match":{"$":"De"}},{"$":" volgende > "},{"match":{"$":"dag"}},{"$":" zat Esther in > "},{"match":{"$":"de"}},{"$":" bibliotheek achter een stapel boeken over > psychiatrie en psychopathologie.\n "}] > > Important thing is the matches at the correct position. > > Bye, Eduard > > -----Original Message----- > *From*: Jean-Paul Rehr <re...@gm... > <Jean-Paul%20Rehr%20%3cr...@gm...%3e>> > *To*: Eduard Drenth <ed...@fr... > <Eduard%20Drenth%20%3ce...@fr...%3e>> > *Cc*: Exi...@li... <Exi...@li... > <%22E...@li...%22%20%3cE...@li...%3e> > > > *Subject*: Re: [Exist-open] json serialization > *Date*: Tue, 05 Jan 2021 10:39:44 +0100 > > Dear Eduard, can you provide an example of what you wish the json output > to look like? > > Best for the new year, > JPR > > On Tue, Jan 5, 2021 at 10:17 AM Eduard Drenth <ed...@fr...> > wrote: > > Dear all, > > This xml snippet: > > <text> > > <match>De</match> > > volgende > > <match>dag</match> > > zat Esther in > > <match>de</match> > > bibliotheek achter een stapel boeken over psychiatrie en psychopathologie. > > </text> > > > Is turned into the below json when using fn:serialize: > > > > As you can see, the match children are serialized first, which makes it > impossible to get the matching right. > > The order of this serialization seems wrong, can this be configured / > fixed? > > Regards, Eduard > > -- > > > Eduard Drenth, Software Architekt > > ed...@fr... > > Doelestrjitte 8 > 8911 DX Ljouwert > +31 58 234 30 47 > +31 62 094 34 28 (privé) > > skype: eduarddrenth > https://github.com/eduarddrenth > frisian.eu > gpg: https://pgp.surfnet.nl/pks/lookup?search=eduarddrenth > > > Op freed bin ik thús/wurkje ik minder > > > > _______________________________________________ > Exist-open mailing list > Exi...@li... > https://lists.sourceforge.net/lists/listinfo/exist-open > > -- > > Eduard Drenth, Software Architekt > > ed...@fr... > > Doelestrjitte 8 > 8911 DX Ljouwert > +31 58 234 30 47 > +31 62 094 34 28 (privé) > > skype: eduarddrenth > https://github.com/eduarddrenth > frisian.eu > gpg: https://pgp.surfnet.nl/pks/lookup?search=eduarddrenth > > > Op freed bin ik thús/wurkje ik minder > > > > _______________________________________________ > Exist-open mailing list > Exi...@li... > https://lists.sourceforge.net/lists/listinfo/exist-open > |