Assuming the following JSON (based on your example but with the outer json object wrapper)
{
"price_lines" : [{
"price": "159.65",
"rate": 0.19,
"title": "MwSt"
},
{
"price": "123.65",
"rate": 0.17,
"title": "Tax2"
},
{
"price": "12.65",
"rate": 0.17,
"title": "Tax2"
}]
}
Parsing Code:
<#assign row = target.addRow()>
<#list json as j >
<#assign row = target.addRow()>
${addColumns(row, j["price_lines"][0], "price1_")}
${addColumns(row, j["price_lines"][1], "price2_")}
${addColumns(row, j["price_lines"][2], "price3_")}
</#list>
In this case you have to address the specific prices in the array explicitly.
Another more generic approach is this:
<#assign row = target.addRow()>
<#list json as j >
<#assign row = target.addRow()>
${addColumns(row, j["price_lines"], "price_")}
</#list>
Which will give you this:
In this case you can have N number of prices. You could then split to get a specific price in a SpreadsheetMapper later:
e.g.
${price_price!?split(","[1])} to get the second price.
It looks like there are not always 3 prices. E.g. when you do ${addColumns(row, j["price_lines"][2], "price3_")} but there is no 3rd price, then this parameter is null.
This is what the error is telling you.
You could try wrapping each line in an additional check:
<#if j["price_lines"][0]??>
${addColumns(row, j["price_lines"][0], "price1_")}
</#if>
<#if j["price_lines"][1]??>
${addColumns(row, j["price_lines"][1], "price2_")}
</#if>
etc.