Is it possible to parse an JSON file from datamapper into workflow variables, with a script ?
It looks like the json file contains a lot of extra info from the datamapper.
JSON sting returned by the datamapper:
[{“schema”:{“columns”:{“TAG_AFB”:“HTMLSTRING”,“ExtraData”:“STRING”}},“id”:27041,“boundaries”:{“start”:0,“end”:3},“datasetid”:4294,“fields”:{“TAG_AFB”:“TAG_AFB:Afbud_frase1”,“ExtraData”:“”}}]
I need the data form TAG_AFB parsed to a workflow variable.
Tried the script i normally use, but it is not working - properly cause of the extra data in the json file.
Before I just parsed the data from the datamapper in an xml file, it is working but i have to use a xml translater after that to get the danish extra letters to work and that translater fails with conversion errors multiple times a day. So will try the json “Way” if it is posible.
Please use the “JSON.stringify()” method for setting the JSON object ‘FileMetaJSON[“TAG_AFB”]’ as the value for the Local Variable “TADG_AFB”, like for example:
Well it is still the same when i use the JSON.stringify nothing is passed to the variables
I have added the json file.TestData.txt (1.1 KB)
JScript:
var FileMetaJSON = JSON.parse(Watch.ExpandString(‘%c’));
Watch.Log(JSON.stringify(FileMetaJSON), 4);
Let start at the beginning. I’m afraid that JSON.parse(Watch.ExpandString("%c")) doesn’t work because the shared text file contains the BOM characters  at the beginning of the first line. So an option is to find a way to remove these BOM characters from the first line or another option is–if possible–to use a different encoding like UTF-8, instead of UTF-8-BOM.
Are you executing the Run Script plugin directly after the Execute Data Mapping plugin?