-
Hi @jreyesr, I have moved on trying a more complex scenario and am being faced with the issue below while loading the json data into the Carbone node. Unexpected token B in JSON at position 14 On another note, it seems that Aggregators is not supported? E.g aggSum More details below: The workflow: The issue: Strangely, when I load the json data into the context directly, its working. Below is the full error log from n8n: { Error log from Terminal: NodeOperationError: Unexpected token B in JSON at position 14 |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Hello @JV300381! I think that the first issue, the Unexpected token B, is because the JSON that is being provided to the Context field isn't actually valid JSON. The values that are strings (namely, BASIC SALARY and EARNINGS) should be wrapped in double quotes: {"reportname":"BASIC SALARY","reportvalue":35000,"reporttype":"EARNINGS"} Double quotes are missing here: The JSON that is being passed now, that is,
To fix that, try the following Expression on the Context field. Note that quotes have been added around the two
Yes, that's because when you hardcoded the JSON data in the Context, it contained the correct quotes, so it parsed correctly Regarding the missing aggregators: Yes, sadly Aggregators are an Enterprise/Cloud-only feature. Carbone Enterprise is paid (though note that there's a free Cloud tier that provides, I think, 100 documents per month at no cost, but requires a credit card) and uses a different method of interaction (it's based on REST API calls, rather than an embedded Javascript library). If you're able to use Enterprise (say, you're doing this for a company and can convince them to cough up the requisite money, or the free Cloud tier is enough for you) and sending documents off to the cloud isn't a deal breaker, you should be able to use this community node instead of mine. Or just use the HTTP Request node, that should work too, since the API is fairly simple. If you'd rather stick with local rendering, I'd recommend precomputing those aggregates before rendering happens. For example, say that you want to do this (print the sum of the You could instead add a Set node before the Carbone node and add a new field with the following Expression (or something that does the same, I just happen to find the functional map-then-reduce style natural for this case):
This first picks out the And then you can pass that JSON document to the template and just do |
Beta Was this translation helpful? Give feedback.
Hello @JV300381!
I think that the first issue, the Unexpected token B, is because the JSON that is being provided to the Context field isn't actually valid JSON. The values that are strings (namely, BASIC SALARY and EARNINGS) should be wrapped in double quotes:
Double quotes are missing here:
The JSON that is being passed now, that is,
{"reportname":BASIC SALARY,"reportvalue":35000, "reporttype":EARNINGS}
, doesn't comply with the JSON syntax. After{"reportname":
, there should come either:{"reportname":"A STRING", ...}
), which is what you want, and strings always start with a double quote"
, not B