Skip to content

regression: Fail to unmarshal JSON arrays #4361

@JoshStrobl

Description

@JoshStrobl

As of Hugo 0.35, I am no longer able to parse a valid JSON file for use in .Site.Data.var. Running --debug reports:

WARN 2018/01/31 17:26:12 Failed to read data from mirrors.json/mirrors.json: json: cannot unmarshal array into Go value of type map[string]interface {}                                                
WARN 2018/01/31 17:26:12 Failed to read data from sws.json/sws.json: json: cannot unmarshal array into Go value of type map[string]interface {}

mirrors.json is saved in data/, with the contents of:

[
	{
		"Latitude": 52.3702,
		"Location": "Amsterdam",
		"Longitude": 4.8952,
		"Type": "official",
		"Url": "https://stroblindustries.com/isos/"
	},
	{
		"Latitude": 33.753746,
		"Location": "Atlanta",
		"Longitude": -84.386330,
		"Type": "official",
		"Url": "http://us.justin.id.au/iso/"
	},
	{
		"Latitude": 52.5200,
		"Location": "Germany",
		"Longitude": 13.4050,
		"Type": "community",
		"Url": "http://solus.veatnet.de/iso/"
	},
	{
		"Latitude": 51.507351,
		"Location": "London",
		"Longitude": -0.127758,
		"Type": "official",
		"Url": "https://soluslond1iso.stroblindustries.com/"
	},
	{
		"Latitude": 40.357298,
		"Location": "New Jersey",
		"Longitude": -74.667223,
		"Type": "community",
		"Url": "http://mirror.math.princeton.edu/pub/solus-iso/"
	},
	{
		"Latitude": 43.086002,
		"Location": "Rochester",
		"Longitude": -77.674538,
		"Type": "community",
		"Url": "https://mirrors.rit.edu/solus/images/"
	},
	{
		"Latitude": 37.7749,
		"Location": "San Francisco",
		"Longitude": -122.4194,
		"Type": "official",
		"Url": "https://solussf1iso.stroblindustries.com/"
	}
]

sws.json is saved in data/, with the contents of:

[
	{
		"episode": "10",
		"description": "The team talks about work done since the snapshot 2017.04.18.0, ferryd, cuppa, plans for the new site, and more.",
		"date": "Fri, 14 Apr 2017 01:33:12 +0300",
		"length": [
			"21474938",
			"43046701"
		],
		"twis": "/2017/04/24/this-week-in-solus-install-43"
	}
]

The failing to parse this JSON results in errors like:

ERROR 2018/01/31 17:26:12 error processing shortcode "theme/shortcodes/sundays-with-solus.html" for page "blog/2017-04-24-this-week-in-solus-install-43.md": template: theme/shortcodes/sundays-with-so
lus.html:6:10: executing "theme/shortcodes/sundays-with-solus.html" at <where $site.Data.sws...>: error calling where: can't iterate over <nil>

With the respective line that it's erroring having: {{ range where $site.Data.sws "episode" "==" $episode }}


I can confirm that it works as intended with Hugo 0.34, I released a blog not just yesterday, were both the Sundays with Solus shortcode, as well as Download mirrors dropdown work as intended. See https://solus-project.com/blog/ and https://solus-project.com/download/

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions