diff --git a/spec/j2x_spec.js b/spec/j2x_spec.js index 79ec6ecb..73209f6a 100644 --- a/spec/j2x_spec.js +++ b/spec/j2x_spec.js @@ -482,7 +482,20 @@ describe("XMLBuilder", function() { const expected = `12`; expect(result).toEqual(expected); }); - + + it("should correctly handle values with oneListGroup", function() { + const jObj = { + "a": [ + "(first)", + "(second)" + ], + }; + const builder = new XMLBuilder({oneListGroup:"true", attributesGroupName: "@"}); + const result = builder.build(jObj); + const expected = `(first)(second)`; + expect(result).toEqual(expected); + }); + it('should build tag with only text node', async () => { const schema_obj = { field: { diff --git a/src/xmlbuilder/json2xml.js b/src/xmlbuilder/json2xml.js index 5707ee0f..6fe3f60c 100644 --- a/src/xmlbuilder/json2xml.js +++ b/src/xmlbuilder/json2xml.js @@ -130,7 +130,13 @@ Builder.prototype.j2x = function(jObj, level) { listTagVal += this.processTextOrObjNode(item, key, level) } } else { - listTagVal += this.buildTextValNode(item, key, '', level); + if (this.options.oneListGroup) { + let textValue = this.options.tagValueProcessor(key, item); + textValue = this.replaceEntitiesValue(textValue); + listTagVal += textValue; + } else { + listTagVal += this.buildTextValNode(item, key, '', level); + } } } if(this.options.oneListGroup){