Array of numbers in JSON (0.109 vs 0.110)

For a fuse.js search, I create a json file.

With Hugo 0.109:

[{"NPA":["1853","1856","1860"],...

With Hugo 0.110:

[{"NPA":[1853,1856,1860],...

So with 110, I have an array of numbers. With 109 I had an array of strings. The fuse.js is broken with the 110 version (but it is my problem). I’m going to debug.

Here is my question. Where does this change in the final JSON come from:

  • YAML metadata parsing?
  • the jsonify filter transformation?
  • the minification?

My repo is here: GitHub - nfriedli/ma-paroisse.ch: Un site simple pour retrouver une paroisse réformée de Suisse romande en 5 secondes.
And the JSON generator is here: ma-paroisse.ch/index.json.json at main · nfriedli/ma-paroisse.ch · GitHub

Subsidiary question. Is it possible to force an array of strings instead of an array of numbers, even if the input is int / numbers in YAML?

See https://github.com/gohugoio/hugo/pull/10625 which fixed https://github.com/gohugoio/hugo/issues/10624.

1 Like

Thank you. I was sure I saw something go by but I couldn’t find it anymore.

And do you have an idea for this? Is it possible to force an array of strings (in the final JSON) instead of an array of numbers, even if the input is int / numbers in YAML?

NB: I may also pass all these numbers in string with a simple regexp in my editor.

That’s the right way to do it.

Otherwise, I suppose you could do:

{{ $strings := apply .Params.foo "string" "."  }}
1 Like

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