Skip to content

Keys of parsed JSON objects are escaped #14

@janikrabe

Description

@janikrabe

The json::object::parse_pair function calls getQuoted to parse object keys. This means that object::_data contains JSON-escaped keys.

This causes the following issue in timewarrior as of GothenburgBitFactory/timewarrior@bdb28fa:

$ timew start '"a'
  Note: '"\"a"' is a new tag.
  Tracking "\"a"
    […]

$ timew stop
  Trying to decrement non-existent tag '"a'

After timew start is run, the tags.data file contains {"\"a":{"count":1}}. When running timew stop, libshared's parse_pair parses the key "\"a", but does not unescape it. This causes timewarrior not to find "a because the key is internally stored as \"a.

Possible solutions:

  • Add a function to retrieve the key name in unescaped form and change timewarrior to use this function
  • Change the internal representation of _data to store the unescaped string

Possibly related to GothenburgBitFactory/timewarrior#159

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions