Comments (4)
This problem is caused by incorrect using of position() in function xqjson:serializeJSONObject.
To fix it, you can change the function from:
declare %private function xqjson:serializeJSONObject($e as element())
as xs:string*
{
"{",
$e/*/(
if(position() = 1) then () else ",",
'"', xqjson:escape-json-string(@name), '":',
xqjson:serializeJSONElement(.)
),
"}"
};
to this:
declare %private function xqjson:serializeJSONObject($e as element())
as xs:string*
{
"{",
for $el at $pos in $e/* return
(
if($pos = 1) then () else ",",
'"', xqjson:escape-json-string($el/@name), '":',
xqjson:serializeJSONElement($el)
),
"}"
};
from xqjson.
Wonderful! I'd be happy to accept a pull request with this fix.
from xqjson.
Thanks for the pull request, @Albicocca. After further testing with the test example in this issue, I realized that I need to apply your logic to xqjson:serializeJSONArray()
too. Now works.
from xqjson.
Fixed by d193107
from xqjson.
Related Issues (8)
- Bug in eXist 2.0 position() function causes invalid JSON serialization HOT 1
- error when unescaping json string containing U+00B7 HOT 9
- Add tests HOT 1
- release 0.1.6 not available via exist-db public repo HOT 1
- Rename functions HOT 8
- Regression in 0.2.0? HOT 3
- Announce deprecation in favor of XQuery 3.1 support HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from xqjson.