Skip to content

Parser can't handle single quotes (instead of double quotes) #160

Description

@jeremy-tafi
data := "{'value':'data'}"
str, err := jsonparser.GetString([]byte(data), "value")
if err != nil {
	fmt.Print(err)
} else {
  fmt.Print(str)
}

This example fails to find the key "value" because it is surrounded by single quotes instead of double quotes. Even though "technically", they should be double quotes, it'd be nice if the parser handled single quotes interchangeably.

Activity

  1. nicpottier commented on Mar 29, 2019

    @nicpottier

    That's not valid JSON, keys and sting values must be surrounded by double quotes:
    https://www.json.org/

  2. jeremy-tafi commented on Mar 29, 2019

    @jeremy-tafi
    Author
  3. remychantenay commented on May 19, 2020

    @remychantenay

    That's true, but in programming languages, especially when trying to encapsulate JSON or other strings, single quotes and double quotes are used interchangeably. It would be nice for the library to support it.
    …

    Well, that’s just not a good practice.

  4. buger commented on Jul 28, 2026

    @buger
    Owner

    Implemented in v1.5.0 — single-quote support is now available via the Config struct: Lenient.Get(data, "key") parses {'key':'value'}. The default remains strict (RFC 8259 double-quote only). See: https://github.com/buger/jsonparser/releases

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