vec/vec_json
Values
pub fn vec2(
from vector: vec2.Vec2(value),
of inner_type: fn(value) -> json.Json,
) -> json.Json
Encode a Vec2
into a JSON object.
Examples
Vec2("a", "b") |> vec2(json.string) |> json.to_string()
// -> { x: "a", y: "b" }
pub fn vec2f(from vector: vec2.Vec2(Float)) -> json.Json
Encode a Vec2f
into a JSON object.
Examples
Vec2(0.1, 1.2) |> vec2f() |> json.to_string()
// -> { x: 0.1, y: 1.2 }
pub fn vec2i(from vector: vec2.Vec2(Int)) -> json.Json
Encode a Vec2i
into a JSON object.
Examples
Vec2(0, 1) |> vec2i() |> json.to_string()
// -> { x: 0, y: 1 }
pub fn vec3(
from vector: vec3.Vec3(value),
of inner_type: fn(value) -> json.Json,
) -> json.Json
Encode a Vec3
into a JSON object.
Examples
Vec3("a", "b", "c") |> vec3(json.string) |> json.to_string()
// -> { x: "a", y: "b", z: "c" }
pub fn vec3f(from vector: vec3.Vec3(Float)) -> json.Json
Encode a Vec3f
into a JSON object.
Examples
Vec3(0.1, 1.2, 2.3) |> vec3f() |> json.to_string()
// -> { x: 0.1, y: 1.2, z: 2.3 }
pub fn vec3i(from vector: vec3.Vec3(Int)) -> json.Json
Encode a Vec3i
into a JSON object.
Examples
Vec3(0, 1, 2) |> vec3i() |> json.to_string()
// -> { x: 0, y: 1, z: 2 }
pub fn vec4(
from vector: vec4.Vec4(value),
of inner_type: fn(value) -> json.Json,
) -> json.Json
Encode a Vec4
into a JSON object.
Examples
Vec4("a", "b", "c", "d") |> vec4(json.string) |> json.to_string()
// -> { x: "a", y: "b", z: "c", w: "d" }