Module : lang.value

Version : 1.0.0

Module Overview

This module provides lang library operations common to all values defined by the language specification 2020R1.

Functions

clone

Returns a clone of v. A clone is a deep copy that does not copy immutable subtrees. A clone can therefore safely be used concurrently with the original. It corresponds to the Clone(v) abstract operation, defined in the Ballerina Language Specification.

cloneReadOnly

Returns a clone of v that is read-only, i.e.

cloneWithType

Constructs a value with a specified type by cloning another value.

fromJsonString

Parses a string in JSON format and returns the the value that it represents. All numbers in the JSON will be represented as float values. Returns an error if the string cannot be parsed.

fromJsonStringWithType

Converts a string in JSON format to a user-specified type. This is a combination of fromJsonString followed by fromJsonWithType.

fromJsonWithType

Converts a value of type json to a user-specified type. This works the same as cloneWithType, except that it also does the inverse of the conversions done by toJson.

isReadOnly

Tests whether v is read-only, i.e.

mergeJson

Merges two json values.

toJson

Converts a value of type anydata to json. This does a deep copy of v converting values that do not belong to json into values that do. A value of type xml is converted into a string as if by the toString function. A value of type table is converted into a list of mappings one for each row. The inherent type of arrays in the return value will be json[] and of mappings will be map<json>. A new copy is made of all structural values, including immutable values.

toJsonString

Returns the string that represents v in JSON format. v is first converted to json as if by the toJson function.

toString

Performs a minimal conversion of a value to a string. The conversion is minimal in particular in the sense that the conversion applied to a value that is already a string does nothing.