Converting back to JSON
See original GitHub issueIs it possible to convert back to JSON from form data in node?
My use case is that I would like to assert the form data I have sent has been mapped correctly
I.E the flow is
JSON data
> Mapped to correct structure
> Form data created
> Payload sent
This would then be used to perform tests like the code below demonstrate ( Nock will pass my the API calls payload automatically making these kind of tests very convenient )
expect(formPayload.products.length).toEqual(originalJSON.items.length)
Issue Analytics
- State:
- Created 4 years ago
- Reactions:6
- Comments:7 (1 by maintainers)
Top Results From Across the Web
Reverse of JSON.stringify? - Stack Overflow
I read the OP as saying "I converted a javascript object to a JSON string, and now I want to convert it back...
Read more >Converting Javascript Objects into Strings with JSON.stringify()
JSON stringification is the process of converting a Javascript object to a flat JSON string that can be used inside a program.
Read more >Convert an Object to JSON String using JavaScript | bobbyhadz
Use the `JSON.stringify()` method to convert an object to a JSON string, ... The method takes a value, converts it to a JSON...
Read more >JSON methods, toJSON - The Modern JavaScript Tutorial
JSON.stringify to convert objects into JSON. JSON.parse to convert JSON back into an object. For instance, here we JSON.stringify a student:.
Read more >JSON.stringify() - JavaScript - MDN Web Docs
The JSON.stringify() method converts a JavaScript value to a JSON string, optionally replacing values if a replacer function is specified or ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
If this library implemented the official FormData API specifications we would be able to iterate over instances and return key value pairs.
@alexindigo thanks for the information - the issue is I don’t have scope to the stream within my tests I just have a string which looks like the following
Do you know if I can convert this without writing some hacky parser myself?
At the minute i’m just doing some nasty
type assertions whereas i’d much rather be targeting specific nodes