vec/vec_json

Values

pub fn vec2_decoder(
  of inner: decode.Decoder(value),
) -> decode.Decoder(vec2.Vec2(value))

A decoder that decodes 2D vectors where all elements are decoded with a given decoder.

Examples

"{\"x\":\"a\",y:\"b\"}"
|> json.parse(vec2_decoder(of: json.string))
// -> Vec2("a", "b", "c", "d")
pub fn vec2_to_json(
  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_to_json(json.string)
// -> { x: "a", y: "b" }
pub fn vec3_decoder(
  of inner: decode.Decoder(value),
) -> decode.Decoder(vec3.Vec3(value))

A decoder that decodes 3D vectors where all elements are decoded with a given decoder.

Examples

"{\"x\":\"a\",y:\"b\",z:\"c\"}"
|> json.parse(vec3_decoder(of: json.string))
// -> Vec3("a", "b", "c")
pub fn vec3_to_json(
  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_to_json(json.string)
// -> { x: "a", y: "b", z: "c" }
pub fn vec4_decoder(
  of inner: decode.Decoder(value),
) -> decode.Decoder(vec4.Vec4(value))

A decoder that decodes 4D vectors where all elements are decoded with a given decoder.

Examples

"{\"x\":\"a\",y:\"b\",z:\"c\",w:\"d\"}"
|> json.parse(vec4_decoder(of: json.string))
// -> Vec4("a", "b", "c", "d")
pub fn vec4_to_json(
  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_to_json(json.string)
// -> { x: "a", y: "b", z: "c", w: "d" }
Search Document