Skip to content

encoding/json inconsistent treatment of runes #6061

@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

Json marshal correctly handles runes, unmarshal doesn't.

package json_rune

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

main :: proc() {
	m := marshal_rune()
	unmarshal_rune(m)
}
marshal_rune :: proc() -> []u8 {
	val, err := json.marshal('a')
	if err != nil {
		fmt.eprintln("Error, json marshal not working with runes")
	} else {
		fmt.println("json marshal works with runes:", string(val))
	}
	return val
}
unmarshal_rune :: proc(data: []u8) {
	r: rune
	err := json.unmarshal(data, &r)
	if err != nil {
		fmt.eprintln("error, json unmarshal not working with runes")
	} else {
		fmt.println("json unmarshal works with runes:", r)
	}
}

Expected Behavior

json marshal works with runes: "a"
json unmarshal works with runes: a

or

Error, json marshal not working with runes
error, json unmarshal not working with runes

Current Behavior

json marshal works with runes: "a"
error, json unmarshal not working with runes

Steps to Reproduce

Run the sample 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