Cheedoong / xml2json

A header-only C++ library converts XML to JSON
MIT License
300 stars 102 forks source link

to_array_form on all nodes #6

Closed feyzprod closed 8 years ago

feyzprod commented 8 years ago

At the moment the function to_array_form is called only when we reach a node that already exist

if a node exist only once there will be no index [0] for that node

`if(name_count[current_name] > 1 && name_ptr)
                to_array_form(name_ptr, jsvalue, jsvalue_chd, allocator);
            else
            {
                jn.SetString(name_ptr, allocator);
                jsvalue.AddMember(jn, jsvalue_chd, allocator);

                to_array_form(name_ptr, jsvalue, jsvalue_chd, allocator); // tried this
            }`

When I call to_array_form function on the first node its always add empty index [1]

<Customer>Test</Customer>

I get

`[Customer] => Array
            (
                [0] => Test

                [1] => 
            )`