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

Alteryx designer Discussions

Find answers, ask questions, and share expertise about Alteryx Designer.
SOLVED

Help with parsing JSON file

Alteryx Certified Partner

I seem to be stuck on even start to parse a fetched json file, since I am getting the error

 

ConvError: JSON Parse (9): Error message: Invalid value. at character position: 0

So, as you can see, the error occurs even before I get started.

 

The workflow is rather simple

2019-01-23 21_05_27-Alteryx Designer x64 - GetSwedishHouseholds.yxmd.pngSimple Workflow

  1. I am trying to fetch some data from http://api.scb.se/OV0104/v1/doris/en/ssd/START/BE/BE0101/BE0101S/HushallT05, by posting a request in JSON format (Number of Households in Sweden)
  2. I do retrieve a JSON answer, but I suspect that it is the encoding that is the challenge

If I save the result to a temporary file, I can see that the encoding is not UTF-8 but UTF-8 BOM, and those extra bytes in the start makes a big difference.

 

But right now I can't think of a workaround, so I ask the community for some assistance.

 

Any tips or tricks I haven't thought of?

 

Br
/Thomas

 

Alteryx Certified Partner

While I am waiting for a more clever answer that this, I did some further spelunking and came up with this 

2019-01-23 21_39_18-Alteryx Designer x64 - GetSwedishHouseholds.yxmd_.pngNew Workflow

So apparently the problem with UTF-8 with BOM is the extra bytes

 

So here I convert the BLOB to a HEX encoded Binary data, then used RegEx to remove those extra bytes.

And I lack of knowledge, I then convert that new HEX encoded Binary back to a BLOB, and the back again from BLOB to Text Encoded string with codepage UTF-8, and then I can parse the JSON file.....

 

But I hope that there is a smarter/easier way than this

 

/Thomas

Meteoroid

Verasko,

 

Were you able to find a more simple work around for this issue? I have a workflow utilizing an JSON API call that has been working for over a year and just recently started throwing the same "Invalid value. at character position: 0" error. Your solution worked, but I'm not certain what caused the error all of a sudden.

Labels