Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Configuration option jsonPropertiesFilter does not work #59

Open
erotavlas opened this issue Aug 18, 2017 · 1 comment
Open

Configuration option jsonPropertiesFilter does not work #59

erotavlas opened this issue Aug 18, 2017 · 1 comment

Comments

@erotavlas
Copy link

erotavlas commented Aug 18, 2017

I was trying to remove a property from the output XML using jsonPropertiesFilter, but no matter what I put in the array, it removes all properties.

                var converter = new x2js({
                    // Escaping XML characters. Default is true from v1.1.0+
                    escapeMode: true,
                    // XML attributes prefix. Default is "_"
                    attributePrefix: "_",

                    // Array access form (none|property). 
                    // Use this property if you want X2JS generate additional property <element>_asArray 
                    // to access in array form any element
                    // Default is 'none' from v1.1.0+
                    arrayAccessForm: "none",

                    // Handling empty nodes (text|object). 
                    // When X2JS found empty node like <test></test> it will be transformed to test : '' for 'text' mode, 
                    // or to Object for 'object' mode  
                    // Default is 'text'
                    emptyNodeForm: "text",

                    // Enable/Disable auxiliary function in generated JSON object to print text nodes with __text/__cdata
                    // Default is true
                    enableToStringFunc: true,

                    // Array access paths (array). 
                    // Use this option to configure paths to XML elements always in "array form". 
                    // You can configure beforehand paths to all your array elements based on XSD or your knowledge
                    // about XML structure
                    // Every path could be a simple string (like 'parent.child1.child2'), a regex (like /.*\.child2/), or a custom function
                    // Default is empty array
                    arrayAccessFormPaths: [],
                    // Strip whitespaces (trimming text nodes)
                    stripWhitespaces: true,

                    // Skip empty text tags for nodes with children
                    skipEmptyTextNodesForObj: true,

                    // DateTime access paths (array). 
                    // Use this option to configure paths to XML elements for "datetimes form". 
                    // You can configure beforehand paths to all your array elements based on XSD or your knowledge
                    // about XML structure
                    // Every path could be a simple string (like 'parent.child1.child2'), a regex (like /.*\.child2/), or a custom function
                    // Default is empty array
                    datetimeAccessFormPaths: [],

                    jsonPropertiesFilter: ['TYPE_NAME']

                });

                var XMLstring = converter.json2xml_str(jObj);
@mellis481
Copy link

I'm having this same issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants