Skip to content

Unmarshal modifies input data #138

Open
@jpcosal

Description

@jpcosal

When input data contains strings with escaped characters (e.g. "/"), input byte array passed to gojay.Unmarshal is altered.

A sample code is given below

package main

import (
	"log"

	"github.com/francoispqt/gojay"
)

func main() {
	data := []byte(`"msn.com\/fr-fr"`)
	var s string
	if err := gojay.Unmarshal(data, &s); err != nil {
		log.Println(err)
	}
	log.Printf("buffer is: %s\n", string(data))
}

This outputs "msn.com/fr-fr"", while original buffer is "msn.com\/fr-fr".
This is a problem because we need to use the original buffer as is to do other processing.

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