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

V3 to V4 migration guide? #623

Closed
4 tasks
tylerblox opened this issue Nov 6, 2023 · 5 comments
Closed
4 tasks

V3 to V4 migration guide? #623

tylerblox opened this issue Nov 6, 2023 · 5 comments

Comments

@tylerblox
Copy link

tylerblox commented Nov 6, 2023

  • Are you running the latest version?
  • Have you included sample input, output, error, and expected output?
  • Have you checked if you are using correct configuration?
  • Did you try online tool?

Description

Input

I'm wondering if there is any support for the methods from version 3 as I begin a migration to LTS version of fast-xml-parser

I use provider.getTraversalObj() in my project to extract the children nodes, and metatdata from xml files. Is there a solution where I can continue to use getTraversalObject to get the intermediate object, or alternatively, is there a guide for migrating away from using it?
Thank you in advance for the help/advice.

Code

const XMLParser = require('fast-xml-parser');


xmlTraverser = XMLParser.getTraversalObj(fileData, FAST_XML_OPTIONS);
const childNodes = Object.keys(xmlTraverser.child);
const rootNode = childNodes[0];

Output

In V4, the getTraversalObj function has been removed

Bookmark this repository for further updates. Visit SoloThought to know about recent features.

Copy link

github-actions bot commented Nov 6, 2023

We're glad you find this project helpful. We'll try to address this issue ASAP. You can vist https://solothought.com to know recent features. Don't forget to star this repo.

@amitguptagwl
Copy link
Member

Hi @tylerblox ,
In version 4, there is a property to preserve the order of js properties. If it is set to true then you get intermediate object that you can use for traversal.

@tylerblox
Copy link
Author

tylerblox commented Nov 13, 2023

Hi @tylerblox , In version 4, there is a property to preserve the order of js properties. If it is set to true then you get intermediate object that you can use for traversal.

I'll try and play around with that a bit, adding that attribute to the config object didn't solve the problem by itself, but I'll see if I've missed something.

After checking on the XmlParser object created, there is no method on it called "getTraversalObject" even after adding the attribute preserveOrder

@amitguptagwl
Copy link
Member

@tylerblox Sorry for the confusion what I meant to say is that "getTraversalObject" has been removed. Instead set preserve order to true to get intermediate object.

@tylerblox
Copy link
Author

@tylerblox Sorry for the confusion what I meant to say is that "getTraversalObject" has been removed. Instead set preserve order to true to get intermediate object.

I see what you mean thank you, I also have a diff of the objects returned in both cases, so I am planning on making the migrations soon. I appreciate the responses greatly.

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