Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

escape html #91

Closed
jney opened this issue Feb 13, 2017 · 2 comments
Closed

escape html #91

jney opened this issue Feb 13, 2017 · 2 comments

Comments

@jney
Copy link

jney commented Feb 13, 2017

Hello, i was wondering if there is a way to remove html escaped characters while parsing a json as standard lib does. i can't find this in documentation.

package main

import (
	"encoding/json"
	"fmt"

	"github.com/buger/jsonparser"
)

func main() {
	e := []byte(`{ "url": "https:\/\/example.com\/" }`)
	url, _, _, _ := jsonparser.Get(e, "url")
	var parsed map[string]interface{}
	json.Unmarshal(e, &parsed)

	fmt.Println("with standard json:", parsed["url"].(string))
	fmt.Println("with jsonparser:", string(url))
}

output

with standard json: https://example.com/
with jsonparser: https:\/\/example.com\/
@buger
Copy link
Owner

buger commented Feb 14, 2017

Try GetString instead.

@jney
Copy link
Author

jney commented Feb 14, 2017

it works, thanks

@jney jney closed this as completed Feb 14, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants