Skip to content

Commit

Permalink
Update json.nim
Browse files Browse the repository at this point in the history
`%` - Conversion of an object or tuple to JsonNode doesn't work correctly for tuples atm, since the generic type is missing. 
Added the tuple generic type to correctly allow tuples as input as well. 
Credits to Elegantbeef from the Nim Discord.
  • Loading branch information
siriuslee69 authored Sep 8, 2024
1 parent 4856bea commit e58cb1b
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/pure/json.nim
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,7 @@ proc `[]=`*(obj: JsonNode, key: string, val: JsonNode) {.inline.} =
assert(obj.kind == JObject)
obj.fields[key] = val

proc `%`*[T: object](o: T): JsonNode =
proc `%`*[T: object | tuple](o: T): JsonNode =
## Construct JsonNode from tuples and objects.
result = newJObject()
for k, v in o.fieldPairs: result[k] = %v
Expand Down

0 comments on commit e58cb1b

Please sign in to comment.