Skip to content

encoding/json incorrect marshal of \x00 character (null terminator) #6060

@AntonGorov195

Description

@AntonGorov195

Context

    Odin:    dev-2025-08:fb4641307
    OS:      Linux Mint 22.1, Linux 6.8.0-90-generic
    CPU:     Intel(R) Core(TM) i5-9400F CPU @ 2.90GHz
    RAM:     15929 MiB
    Backend: LLVM 20.1.8

\x00 is not a valid character in a json string and it should be \u0000.

package null_rune

import "core:encoding/json"
import "core:fmt"

main :: proc() {
	val, err := json.marshal("\x00")
	if err != nil {
		unreachable()
	}
	fmt.println("\"\\u0000\" ==", string(val))
}

Expected Behavior

"\u0000" == "\u0000"

Current Behavior

"\u0000" == "\x00"

Steps to Reproduce

Run the segment code above with odin run .

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions