What format does JSON gets converted to in the input bar for custom code.
Hello,
I am bringing in a json to a custom code step and it just isn’t converting to json to me. Not sure what to do anymore. I’ve defined this simple example to demonstrate:
You can see that I have “input” and “code” to be defined exactly the same. Yet the output for them are different format. I would love input to put output the same as “in_code”
I couldn’t find anything specific to Zapier that would help here.
Thanks!
Page 1 / 1
Hi @Arnoldas
Good question.
Here are help articles for how to convert to JSON:
Your code had an error! Traceback (most recent call last): File "<string>", line 13, in the_function File "/var/lang/lib/python3.7/json/__init__.py", line 348, in loads return _default_decoder.decode(s) File "/var/lang/lib/python3.7/json/decoder.py", line 337, in decode obj, end = self.raw_decode(s, idx=_w(s, 0).end()) File "/var/lang/lib/python3.7/json/decoder.py", line 353, in raw_decode obj, end = self.scan_once(s, idx) JSONDecodeError: Expecting property name enclosed in double quotes: line 1 column 3 (char 2)
let X = inputData.X; // get raw JSON as input X = X.replace(/'/g,'"'); // replace all ' with " X = X.replace(/None/g,'"None"'); // replace None with "None" X = JSON.parse(X); // parse JSON