How can i use json data in markdown files

Hey! I got a problem with JSON data. Let me explain this problem, I got a JSON data and I need to add to the markdown file like this :

app_pricing_plans = [{“name”:“USD”,“price”:“0”,“currency”:“USD”,“type”:“free”},{“name”:“USD”,“price”:“49”,“currency”:“USD”,“type”:“paid”},{“name”:“USD”,“price”:“79”,“currency”:“USD”,“type”:“paid”},{“name”:“USD”,“price”:“299”,“currency”:“USD”,“type”:“paid”}]

when I try to start my website, Hugo shows this error :

unmarshal failed: Near line 33 (last key parsed ‘app_pricing_plans.name’): expected key separator ‘=’, but got ‘:’ instead

It won’t let me use it this way, what can I do?

Thank you for your answer

Quick guess: The outer brackets should be {, the inner brackets [.

Thank you for your answer @davidsneighbour n_n

I solved like this :
[[app_pricing_plans]]
name = “Basic”
price = 299
currency = “USD”
type = “paid”

From the = it looks like you’re using TOML in your front matter, which doesn’t support inline JSON.

You could use YAML instead, which IIRC supports that:

---
app_pricing_plans: [ {“name”:“USD”,“price”:“0”,“currency”:“USD”,“type”:“free”},{“name”:“USD”,“price”:“49”,“currency”:“USD”,“type”:“paid”},{“name”:“USD”,“price”:“79”,“currency”:“USD”,“type”:“paid”},{“name”:“USD”,“price”:“299”,“currency”:“USD”,“type”:“paid”} ]
---

Alternatively, you can put it in the data/ folder as a separate app_pricing_plans.json file and use data templates to access it.

Thanks, @fvbommel n_n
I noted these solutions, i am gonna try it

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.