fromJson
@NotNull
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);
Content copied to clipboard
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
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);
Content copied to clipboard
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