diff --git a/lib/pure/json.nim b/lib/pure/json.nim index a9d0ed4cb08b..ac3c3b19430d 100644 --- a/lib/pure/json.nim +++ b/lib/pure/json.nim @@ -1103,7 +1103,7 @@ when defined(nimFixedForwardGeneric): jsonPath.add '[' jsonPath.addInt i jsonPath.add ']' - initFromJson(dst[i], jsonNode[i], jsonPath) + initFromJson(dst[i.S], jsonNode[i], jsonPath) # `.S` for enum indexed arrays jsonPath.setLen originalJsonPathLen proc initFromJson[T](dst: var Table[string,T]; jsonNode: JsonNode; jsonPath: var string) = diff --git a/tests/stdlib/tjson_enum_index.nim b/tests/stdlib/tjson_enum_index.nim new file mode 100644 index 000000000000..2c24f4f36b2f --- /dev/null +++ b/tests/stdlib/tjson_enum_index.nim @@ -0,0 +1,11 @@ +import json +type Test = enum + one, two, three, four, five +let a = [ + one: 300, + two: 20, + three: 10, + four: 0, + five: -10 +] +doAssert (%* a).to(a.typeof) == a \ No newline at end of file