How to solve/fix JSON.parse problem dealing with duplicates
Hi all
I seem to be facing this problem :
JSON syntax duplicates
This is the source xls file format:
This is the JSON :
- [{"Registrant ID":"22722608","Registrant Date":"09/18/2018","Last Name":"Armstrong","First Name":"Conor","Email":"conor.armstrong@testco.com","Username":"conor.armstrong@testco.com","Company":"TEST CO","Department":"","Title":"","Attendee":"No","Status":"Enrolled","Section":"","Location":"place online"},{"Registrant ID":"22722608","Registrant Date":"09/18/2018","Last Name":"jenkins","First Name":"bob","Email":"bob.jenkins@testco.com","Username":"bob.jenkins@testco.com","Company":"TEST CO","Department":"","Title":"","Attendee":"No","Status":"Enrolled","Section":"","Location":"place online"}]
Here's my fiddle :
As a simple test using only part of the JSON this works fine :
- <!DOCTYPE html>
- <html>
- <body>
- <h2>Create Object from JSON String</h2>
- <p id="filtered"></p>
- <script>
- var txt = '{"Registrant ID":"22722608","Registrant Date":"09/18/2018","Last Name":"Armstrong","First Name":"Conor","Email":"conor.armstrong@testco.com","Username":"conor.armstrong@testco.com","Company":"TEST CO","Department":"","Title":"","Attendee":"No","Status":"Enrolled","Section":"","Location":"place online"}'
- var obj = JSON.parse(txt);
- document.getElementById("filtered").innerHTML = obj['Last Name'] + ", " + obj.Location;
- </script>
- </body>
- </html>
How can I go about solving this ? Is there a way to filter the uploaded XLS file before creating a JSON object?
In a nutshell the above code :
1.uploads an XLS file (demo roster 1 ...attached in this post too )
2.creates a (hopefully filtered JSON object)
3.will finally save as a CSV (On my WISHLIST now)
Is it because the object is an array and I should be dealing with it differently , if so please advise/correct me.
I look forward to any help or advice.
Thank you
Den