-
Notifications
You must be signed in to change notification settings - Fork 606
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
Custom Objects for Tags #164
Comments
Have you tried outputting your opject with Well, your case is not really supported and what you are doing might work, but it might not just as well. I'd probably just let xml2js do its thing and then merge the resulting object with whatever object you already have. |
Tx for responding. As a solution that seems to work what I do is Use xml2js to convert my XML It would be nice to be able to bypass the reconversion into string and the re-parse. So it seems like it would be cool if xml2js had the 'reviver' option ;-) Am I making this more complicated than needed ? Tx |
I have no idea why you would convert to a string. Maybe you should describe what this "reviver" is, because you might be right and doing it more complicated than required. |
Let’s say I start with this XML John Doe Anna Smith Peter JonesI have a class in Javascript called Employee that has all kinds of methods built for it. When I use XML2JS to convert to JSON the ‘employee’ tag is converted to a generic object. I tried using the tagNameProcessors and a function similar to return name That did seem to work. However if I use the JSON.parse method with a reviver I seem to get exactly what I think I need. function ConvertTags(key, value)
} As far as I can tell XML2JS.parse returns an object and JSON.parse needs a string so hence the conversion to string first. |
Sorry XML example didnt post
|
Hello -
Is it possible to have the parser utilize my prebuilt objects when parsing. I've tried using the tagNameProcessors config and it 'sort of' works. I get an object that I define but it's always listed as [object Object] = object when I debug into the return value from the parser
I'm new to Javascript so I'm not sure if what I want is possible and if it is how one would go about it.
Tx for any help.
greg
The text was updated successfully, but these errors were encountered: