Hi Folks,
Processing a minified version of a .json file the tokenparser does not fail, however, if the original file from the Customer comes in formatted,
Then:
|
throw new TokenParserError( |
throws the error
"stack": [
"Runtime.UnhandledPromiseRejection: Error: Error on Readable Stream for s3DropBucket Object acmerepsignature_sampleformatted.json.",
"Error Message: An error has stopped Content Parsing at record 0 for s3 object acmerepsignature_sampleformatted.json.",
**"Error: Unexpected SEPARATOR (\"\\n\") in state VALUE ",**
" at process.<anonymous> (file:///var/runtime/index.mjs:1276:17)",
" at process.emit (node:events:517:28)",
" at emit (node:internal/process/promises:149:20)",
" at processPromiseRejections (node:internal/process/promises:278:11)",
" at process.processTicksAndRejections (node:internal/process/task_queues:96:32)"
]
I first thought there was a value in the json that contained an embedded newline, however, inspecting the file very closely that is not the case.
Editing to add params:
const jsonParser = new JSONParser( {
// numberBufferSize: 64, //64, //0, //undefined, // set to 0 to don't buffer.
stringBufferSize: undefined, //64, //0, //undefined,
separator: '\n', // separator between object. For example \n
for nd-js.
paths: [ '$' ], //ToDo: Possible data transform oppty
keepStack: false,
emitPartialTokens: false // whether to emit tokens mid-parsing.
} )
Here's a short sample of the Original file:
[
{
id: '0051N000006sMsYQAU',
email: '[email protected]',
first: 'Cheryl',
last: 'Basso',
photo: null,
Photo: null,
brandApprovedPhoto: null,
designations: null,
jobTitle: null,
phone: null,
registeredAdvisorTitle: null,
updatedAt: '2022-01-20T02:28:13.077Z'
},
{
id: '0051N000006sMzcQAE',
email: '[email protected]',
first: 'Laura',
last: 'Dern',
photo: null,
Photo: null,
ApprovedPhoto: null,
designations: null,
jobTitle: null,
phone: null,
registeredAdvisorTitle: null,
updatedAt: '2022-01-20T02:28:13.077Z'
},
{
id: '0051N000006sNCiQAM',
email: '[email protected]',
first: 'Brad',
last: 'Bean',
photo: null,
Photo: null,
ApprovedPhoto: null,
designations: null,
jobTitle: null,
phone: null,
registeredAdvisorTitle: null,
updatedAt: '2022-01-20T02:28:13.077Z'
}
]
Of note, it would be helpful if the error message included an index to the character/position within the json that causes the exception,
I've parsed the formatted version independently and it does not fail so hoping someone can provide some insight as to how to go about resolving this?
Having the Customer >>not<< format the file is not an option, just in case that was a thought,
Thanks,
KWL