Hello Community,
My code works fine when I use MD files. But when I try doing the code with JSON (and implementing modifications onto my code to use json), it fails. I am unable to figure out why.
Here is the sample content from the JSON (fcountries.json):
[
{
"FID": "26",
"c_codes": "['au', 'fra', 'afg', 'ind', 'bra']"
},
...
]
And here is the code that I have -
$fruitLocations:= $.Site.Data.fcountries ".c_codes" "intersect" (slice .Params.fc_code)
The purpose of the above code here is - to find out the fruits which are available in a country. And what I am trying to do is search for the incoming fc_code (which is a country code) in the json and list out the IDs.
The above code does not print anything. However, if I create MD files for my json data, then, the following works fine as expected
{{ $fCountry := where $.Site.Pages "Section" "countries" }}
{{ $fCountry := where $fCountry "Params.c_codes" "intersect" (slice .Params.fc_code) }}
Would appreciate if someone here could tell me what I am doing wrong above.
Regards,
Sid.