Skip to content

Should probably avoid $-prefixed properties #29

Description

@lapo-luchini

I'm trying a single example structure (which contains $$hashKey as added by AngularJS during edit) and x2js.json2xml_str is producing a <$$hashKey>030</$$hashKey> node, which then the parser chokes on.
The end effect is that x2js.json2xml(myVar) is always null.
I would expect an exception not a null, but in this case I guess $-prefixed properties should simply be skipped, as they are both reserved in AngularJS and invalid XML tag names anyways.

Right now I'm doing this:

function removeDollars(obj) {
    if (typeof obj != 'object')
        return;
    for (var k in obj) {
        if (k.charAt(0) == '$')
            delete obj[k];
        removeDollars(obj[k]);
    }
}
var data = angular.copy($scope.value);
removeDollars(data);
var xml = x2js.json2xml_str(data);

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions