aboutsummaryrefslogtreecommitdiffstats
path: root/teal-src
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2021-03-19 01:17:59 +0100
committerKim Alvefur <zash@zash.se>2021-03-19 01:17:59 +0100
commit7f04df223a369d7d3bb92cf94d0ad64ad5fb6ac9 (patch)
treeae9544ebae148df5f9159b03df6f913ebaa4efb6 /teal-src
parent3c3cdcd0c7a6895b90d03480bbc9fba69b74008f (diff)
downloadprosody-7f04df223a369d7d3bb92cf94d0ad64ad5fb6ac9.tar.gz
prosody-7f04df223a369d7d3bb92cf94d0ad64ad5fb6ac9.zip
util.datamapper: Fix arrays nesting one level too deep
Diffstat (limited to 'teal-src')
-rw-r--r--teal-src/util/datamapper.tl16
1 files changed, 7 insertions, 9 deletions
diff --git a/teal-src/util/datamapper.tl b/teal-src/util/datamapper.tl
index 28468d2d..f0e7d6bc 100644
--- a/teal-src/util/datamapper.tl
+++ b/teal-src/util/datamapper.tl
@@ -216,7 +216,7 @@ local function parse (schema : json_schema_object, s : st.stanza_t) : table
end
end
-local function unparse ( schema : json_schema_object, t : table, current_name : string, current_ns : string ) : st.stanza_t
+local function unparse ( schema : json_schema_object, t : table, current_name : string, current_ns : string, ctx : st.stanza_t ) : st.stanza_t
if schema.xml then
if schema.xml.name then
@@ -228,7 +228,7 @@ local function unparse ( schema : json_schema_object, t : table, current_name :
-- TODO prefix?
end
- local out = st.stanza(current_name, { xmlns = current_ns })
+ local out = ctx or st.stanza(current_name, { xmlns = current_ns })
if schema.type == "object" then
@@ -303,15 +303,13 @@ local function unparse ( schema : json_schema_object, t : table, current_name :
out:add_direct_child(c);
end
elseif proptype == "array" and propschema is json_schema_object and v is table then
- local c = unparse(propschema, v, name, namespace);
- if c then
- if value_where == "in_wrapper" then
- local w = st.stanza(propschema.xml.name or name, { xmlns = propschema.xml.namespace or namespace })
- w:add_direct_child(c);
- out:add_direct_child(w);
- else
+ if value_where == "in_wrapper" then
+ local c = unparse(propschema, v, name, namespace);
+ if c then
out:add_direct_child(c);
end
+ else
+ unparse(propschema, v, name, namespace, out);
end
else
error "NYI"