cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Need to share some code when posting a question or reply? Make sure to use the "Insert code sample" menu option. Learn more! X

Parsley Parser

reedsch
4-Participant

Parsley Parser

HI James,

This is good work. I'm using this to create a datashape on the fly from an input JSON definition, and that does work, except that the order of fields in the datashape is completely random and bears no relation to the order in the JSON string. 

 Any ideas? I'm importing a .CSV and the datashape order must reflect accurately the order in the .CSV

 

// THE RESULTING DATASHAPE IS NOT IN THE SAME ORDER

var jsonDataDef = '[{"Name":"","System":"", "Assembly":"","SID":"","Part#":""}]';
var jsonDataModel = JSON.parse(jsonDataDef);

 

var params = {
dateFormat: "RAW",
json: jsonDataModel,
dataShape: undefined,
minDataMilliseconds: undefined
};

 

var res = Resources["Parsley"].ParseJSON(params).array;
result = res;

3 REPLIES 3
slangley
23-Emerald II
(To:reedsch)

Hi @reedsch.

 

Apologies for the late response on this.  Since it was originally posted to a topic that already had a solution, this response was overlooked.

 

At this time, the Parsley Advanced Parsing Extension is not supported.  However, you may want to try the CSV Parser which is fully supported.

 

Please let us know if this works for you.

 

Regards.

 

--Sharon

jamesm1
12-Amethyst
(To:slangley)

The problem here is that the CSV parsing extension 1.) only parses CSV, not JSON and 2) requires a DataShape to already be defined, in this case Reedsch does not have a datashape and is using Parsley to define it.

jamesm1
12-Amethyst
(To:reedsch)

Hey @reedsch,

 

I believe there was a bug in the JSON parsing that caused this that I have fixed in a more recent version, which is attached (note that the XLSX parsing in this version will not work, since I did not include the Apache POI libraries). Let me know if this does not resolve the issue, if not I would like to get to the bottom of it. Feel free to shoot me a note at jmccuen@ptc.com.

 

Thanks!

 

Edit: Note - depending on your version of Thingworx, you will need to first delete the existing Parsley extension, restart Tomcat, and reinstall the new Parsley extension before the changes take effect.

Announcements


Top Tags