Skip to content

expvar: output malformed JSON string #7761

@rui314

Description

@rui314
What does 'go version' print?
go version devel +07e31caba5b6 Wed Apr 09 21:50:24 2014 -0700 + linux/amd64

What steps reproduce the problem?
Run this program. http://play.golang.org/p/uO-vW5gC2X

package main

import (
    "expvar"
    "fmt"
)

func main() {
    m := expvar.NewMap("aaa")
    m.Add(`"xxx`, 1)
    fmt.Println(m.String())  // prints {""xxx": 1}
}

What happened?
The program prints a malformed JSON string.

What should have happened instead?
Double quote characters should be escaped by backslash.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions