英文:
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
{
"root": {
"a": "some text",
"name": "some other text"
}
}
Notes:
This issue is specific to calling the element
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.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论