Valid json-stat, error in the value length

11 views
Skip to first unread message

Guido Gay

unread,
Jun 29, 2026, 8:16:45 AM (24 hours ago) Jun 29
to json-stat
THe following is a valid json-stat file (https://json-stat.org/format/validator/):

{
"class":"dataset",
"id":["Kyn","Ár","Ríkisfang","Tegund flutnings"],
"size":[2,2,1,1],
"dimension":{"Kyn":{"category":{"index":{"1":0,"2":1},"label":{"1":"Males","2":"Females"}}},
  "Ár":{"category":{"index":{"2020":0,"2025":1},"label":{"2020":"2020","2025":"2025"}}},
  "Ríkisfang":{"category":{"index":{"1":0},"label":{"1":"Total"}}},
  "Tegund flutnings":{"category":{"index":{"1":0},"label":{"1":"Net immigration"}}}},
"value":[1,2,3,4,5],
"version":"2.0"
}

Reading it with "rjsonstat" (R library) gives the following error:
"Assertion on 'values' failed: Must have length 4, but has length 5."

We get a similar notice using the csv exporter (https://json-stat.org/format/exporter/):

JSON-stat → CSV

The content of your file is not a JSON-stat dataset.


I wonder if it would be possible to modify the full specification (https://json-stat.org/full/) that is a bit too terse on this matter.

Guido Gay

Xavier Badosa

unread,
Jun 29, 2026, 12:54:09 PM (19 hours ago) Jun 29
to json...@googlegroups.com
Guido,

The current validator (https://json-stat.org/format/validator/) is just a "shape" validator: it validates against the JSON-stat Schemas.

Your document can have a JSON-stat shape but still be JSON-stat invalid. That's the case of your example: 

You define a cube of 

"size":[2,2,1,1] 

which requires 2x2x1x1=4 values but "value" has a length of 5:

"value":[1,2,3,4,5]

To address this problem, I'm working on a JSON-stat validator that not only validates the document against schemas but also against a rules' catalog (https://github.com/jsonstat/validator/blob/main/rules-manifest.json).

This validator


is a work in progress (nearly finished).

Xavier

--
You received this message because you are subscribed to the Google Groups "json-stat" group.
To unsubscribe from this group and stop receiving emails from it, send an email to json-stat+...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/json-stat/13ebf59a-6aaa-4f6f-a6d7-b3a9a45f263cn%40googlegroups.com.

Guido Gay

unread,
Jun 29, 2026, 1:15:48 PM (19 hours ago) Jun 29
to json-stat
Thamk you for your kind reply.
Guido
Reply all
Reply to author
Forward
0 new messages