Skip to content

escape html #91

Closed
Closed
@jney

Description

@jney

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\/

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