fromJson

@NotNull
open fun fromJson(@Nullable primitive: @Nullable JsonPrimitive, @NotNull stringFunction: @NotNull (String) -> String): @NotNull KeyframeDatapoint

Reads a numeric value or a Molang expression from a JSON primitive. Null and blank inputs yield zero. The string transformation runs only for trimmed input that cannot be parsed as a float.


var datapoint = KeyframeDatapoint.fromJson(new JsonPrimitive("2.5"), text -> text);

Return

the numeric or expression datapoint

Since

3.7.0

Parameters

primitive

the source primitive, or null

stringFunction

the transformation applied to expression text

Throws

if the string transformation throws


@NotNull
open fun fromJson(@Nullable primitive: @Nullable JsonPrimitive, @NotNull defDatapoint: @NotNull KeyframeDatapoint, @NotNull stringFunction: @NotNull (String) -> String): @NotNull KeyframeDatapoint

Reads a number or Molang expression, using the supplied default for null or blank input. The string transformation applies only to trimmed input that cannot be parsed as a float.


var weight = KeyframeDatapoint.fromJson(null, KeyframeDatapoint.ONE, text -> text);

Return

the numeric, expression, or default datapoint

Since

3.7.0

Parameters

primitive

the source primitive, or null

defDatapoint

the default for null or blank input

stringFunction

the transformation applied to expression text

Throws

if the string transformation throws