MarkLogic json:transform-to-json在元素名称为’name’时抛出’null’。

huangapple go评论64阅读模式
英文:

MarklLogic json:transform-to-json throws 'null' when element name is 'name'

问题

When using json:transform-to-json with "custom" config, the value of my element is transformed as "null". Instead, I expect the text of the element to be displayed.

{
    "root": {
        "a": "some text",
        "name": "some other text"
    }
}

Notes:

This issue is specific to calling the element . It works as expected if you call it something else (e.g., ). But you need to call it .

This might be related to a MarkLogic database setting, as it works in one of our databases but not in others in the same MarkLogic instance. None of the settings seem obviously relevant to JSON transformation.

英文:

When using json:transform-to-json with "custom" config, the value of my <name> element is transformed as "null". Instead, I expect the text of the <name> element to be displayed.

import module namespace json="http://marklogic.com/xdmp/json" at "/MarkLogic/json/json.xqy";

let $myxml := <root><a>some text</a><name>some other text</name></root>

let $jsonConfig := json:config("custom")
    
return json:transform-to-json($myxml,$jsonConfig)

returns

{"root": {
"a": "some text", 
"name": null } }

I expect it to return

{"root": {
"a": "some text", 
"name": "some other text"
}}

Notes:

This is specific to me calling my element <name> and it works as expected if I call it something else (e.g. <names>). But I need to call it <name>.

I think this is a MarkLogic database setting, as it works in one of our databases but not in others in the same MarkLogic instance. None of the settings jump out to me as obviously relevant to JSON transformation.

答案1

得分: 1

我找出了数据库之间的差异来解决这个问题。在MarkLogic管理页面(ML 9)上,我选择了一个不同的数据库作为“模式数据库”,问题得以解决。这一定是我们的模式中存在某些问题。

英文:

I pinpointed the difference between the databases to solve this. On the MarkLogic admin page (ML 9), I selected a different database for the "schema database", and that solved the problem. There must be something in our schemas that causes this.

huangapple
  • 本文由 发表于 2023年4月13日 23:37:26
  • 转载请务必保留本文链接:https://go.coder-hub.com/76007329.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定