Skip to content

Any way to get the _raw_ bytes from the key? (GetRaw("key")) #96

Open
@salmonix

Description

@salmonix

Get("key").String() returns the json string removing the escape characters, while GetStringByte("key") does the same only converting it into a []byte, as

[]byte( Get("key").String() ) ==  GetStringByte("key") 

This raw value, for instance,

<?xml version=\"1.0\" encoding=\"UTF-8\"?>

is turned into

 <?xml version="1.0" encoding="UTF-8"?>

The unescaped value can not be Set directly in the json:

Set("key", fastjson.MustParseBytes(value) ) 

will return error.

This behavior prevents low level modification of the value. For example, replacing placeholders in a bigger xml without parsing the xml data, then re-escaping it would add unnecessary overhead to the whole operation.
Is there any way to retrieve the value in its raw []byte form ?

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