0
votes

Update: the problem was with the file encoding. See answer.

I've got a json payload that is 15.7 MB coming from blob storage. When I pass the output to a ParseJson action I use the json() converter function, but I get this error:

Unable to process template language expressions in action 'Parse_JSON' inputs at line '1' and column '2792': 'The template language function 'json' parameter is not valid.

Then I took the same json file and stripped it down to 1 KB and tested with the same Logic App and it worked. So is there a size limit for json()?

1
Sorry, how are you stripping a 15MB file to just 1KB?Johns-305
Just manually in a text editor and then I uploaded it to blob storage.Joey Eng
Well, specifically, 15MB to 1K is more than an 'edit'. Why was it 15MB to begin with? Stripping so much, you likely removed the actual problem.Johns-305
The file was serialized with Newtonsoft.JSON, so I'm pretty sure the payload itself was valid JSON. Stripping it down to 1K was just a test to see if the size of the file was the problem, and that seems like a possible cause but can't be certain.Joey Eng
@JoeyEng how can you even strip the file manually and reduce the size ? That is removal of the actual data. And you can easily validate the json using jsonlint.comHariHaran

1 Answers

1
votes

The problem was that the stream was written with a byte order mark (BOM) added at the start of the text, so it was not recognized as valid JSON. StreamWriter was used to write to the stream with UTF8 encoding. The fix was to not specify the encoding in the constructor, which defaults to an instance of UTF8 without a BOM:

https://docs.microsoft.com/en-us/dotnet/api/system.io.streamwriter?view=netframework-4.7.2#remarks