Re: Conversion from XML produces invalid JSON

27 views
Skip to first unread message

Joni Freeman

unread,
Aug 10, 2012, 4:27:28 AM8/10/12
to lif...@googlegroups.com
Hi,

Yes this indeed could be enhanced. I don't see why this couldn't convert the above example to:

{ "f": ["1", "2", "3"], "z":"foo" }

I noticed that you already opened a ticket for this. I reopened it now since this is a verified bug.

https://github.com/lift/framework/issues/1305

Cheers Joni

On Thursday, August 9, 2012 8:47:18 PM UTC+3, shveik wrote:

When converting a flat array from xml, when combined with other elements, the resulting JSON is invalid. for example, 
when converting a piece of xml that looks like this: 
<f>1</f>
<f>2</f>
<f>3</f>
, the result is correct : "f" : [1,2,3], however, if we add another node:

<f>1</f>
<f>2</f>
<f>3</f>
<z>foo</z>, the result is something like this: { "f": "1", "f": "2", "f": "3", "z":"foo" }. I believe this is happening because of the array_? definition is checking distinct = 1 for fields of surrounding element. 
a possible solution would be to first group by the name of the node and then do the array check for each group where an array is the map's value where count > 1. that would not drop elements and produce "correct" JSON.

Thanks.

Reply all
Reply to author
Forward
0 new messages