Functions -
lang.value
clone | Returns a clone of |
cloneReadOnly | Returns a clone of |
fromJsonString | Parse a string in JSON format and return 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. |
isReadOnly | Tests whether |
mergeJson | Return the result of merging json value |
toJsonString | Return the string that represents |
toString | Returns a simple, human-readable representation of |
Returns a clone of value
.
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.
Parameters
- value null
-
source value
-
Return Type
(null) clone of
value
Returns a clone of value
that is read-only, i.e. immutable.
It corresponds to the ImmutableClone(v) abstract operation,
defined in the Ballerina Language Specification.
Parameters
- value null
-
source value
-
Return Type
(null) immutable clone of
value
Parse a string in JSON format and return 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.
Parameters
- str string
Tests whether v
is read-only, i.e. immutable
Returns true if read-only, false otherwise.
Parameters
- value null
-
source value
-
Return Type
(boolean) true if read-only, false otherwise
Return the result of merging json value j1
with j2
.
-
Return Type
(json | error) merged json value or error
If the merge fails, then return an error. The merge of j1 with j2 is defined as follows:
- if j1 is (), then the result is j2
- if j2 is nil, then the result is j1
- if j1 is a mapping and j2 is a mapping, then for each entry [k, j] in j2,
set j1[k] to the merge of j1[k] with j
- if j1[k] is undefined, then set j1[k] to j
- if any merge fails, then the merge of j1 with j2 fails
- otherwise, the result is j1.
- otherwise, the merge fails
Return the string that represents v
in JSON format.
Parameters
- v json
-
Return Type
(string) string representation of json
Returns a simple, human-readable representation of value
as a string.
-
Return Type
(string) simple, human-readable string representation of
value
- if
value
is a string, then returnsvalue
- if
value
is()
, then returns an empty string - if
value
is boolean, then the stringtrue
orfalse
- if
value
is an int, then returnvalue
represented as a decimal string - if
value
is a float or decimal, then returnvalue
represented as a decimal string, with a decimal point only if necessary, but without any suffix indicating the type ofvalue
returnNaN
,Infinity
for positive infinity, and-Infinity
for negative infinity - if
value
is a list, then returns the results toString on each member of the list separated by a space character - if
value
is a map, then returns key=value for each member separated by a space character - if
value
is xml, then returnsvalue
in XML format (as if it occurred within an XML element) - if
value
is table, TBD - if
value
is an error, then a string consisting of the following in order- the string
error
- a space character
- the reason string
- if the detail record is non-empty
- a space character
- the result of calling toString on the detail record
- the string
- if
value
is an object, then- if
value
provides atoString
method with a string return type and no required methods, then the result of calling that method onvalue
- otherwise,
object
followed by some implementation-dependent string
- if
- if
value
is any other behavioral type, then the identifier for the behavioral type (function
,future
,service
,typedesc
orhandle
) followed by some implementation-dependent string
Note that
toString
may produce the same string for two Ballerina values that are not equal (in the sense of the==
operator).- if