Skip to content

Parsing error with variant types #104

Description

@sonicsmooth

Parsing bug when there is whitespace before the closing } when parsing a variant type without specifying kind. When the kind is specified the problem goes away. This problem does not exist when parsing non-variant types.

I added eatSpace(s, i) after line 470 skipValue(s, i) which seems to avoid the problem in my case.
I should probably learn how to do pull requests...

Jsony 1.1.6

Nim 2.2.0

import jsony

type
  JunkKind = enum jkJunkA
  MyVariant = object
    name: string
    case kind: JunkKind
      of jkJunkA: junkA: int

echo """{"name": "test1", "kind": "jkJunkA"}""".fromJson(MyVariant) # ok
echo """{"name": "test2", "kind": "jkJunkA" }""".fromJson(MyVariant) # ok
echo """{"name": "test3"}""".fromJson(MyVariant) # ok
echo """{"name": "test4" }""".fromJson(MyVariant) # fail: Expected , but got } instead.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions