node-recurly icon indicating copy to clipboard operation
node-recurly copied to clipboard

Improve 'nil' values support

Open jlescot opened this issue 10 years ago • 0 comments

I ran into a case where I created an Account on Recurly side, and when I get its details, I have the following as response (XML format):

<account>
    ...
    <first_name></first_name>
    <last_name nil="nil"></last_name>
    ...
</account>

which is then converted into (JSON format):

account: {
    ... 
    first_name: '',
    last_name: {
        $: {
            nil: "nil"
        }
    },
    ...
}

whereas I would expect something like:

account: {
    ... 
    first_name: '',
    last_name: null,
    ...
}

It seems that there is no standard convention to convert XML > JSON. BTW, I wonder whether the problem is linked to the library you are using to do the conversion (https://www.npmjs.org/package/xml2js) or whether it is an issue on Recurly side which should not return an XML element with a nil attribute (but instead omitting the element itself could be better...)

So any idea on this problem would be highly appreciated.

jlescot avatar Aug 28 '14 14:08 jlescot