Val
Resource to interact with lists or maps with keys and values (dictionaries). Values is a data storage object that can be represented as a list or as a data map (dictionary). Once initialized as one of these structures, list or map, it can no longer be changed to the other.
const dataMap = _val.map()
.set('id', 1)
.set('name', 'Netuno')
.set('site', 'www.netuno.org')
.set('active', 'true')
const idAsString = dataMap.getString('id')
const name = dataMap['name']
const site = dataMap['site']
const active = dataMap.getBoolean('active')
const dataList = _val.list()
.add('Linha 1')
.push('Linha 2')
.add('Linha 3')
for (const line of dataList) {
_log.info(line)
}
cast
_val.cast(obj: java.lang.Object) : Values
Description
Turns an object into values if possible.
Attributes
NAME | TYPE | DESCRIPTION |
---|---|---|
obj | java.lang.Object | Object to be converted. |
Return
( Values )
The object converted to values.
fromJSON
_val.fromJSON(text: string) : Values
Description
Gets the values of a string with an array or object in JSON.
Attributes
NAME | TYPE | DESCRIPTION |
---|---|---|
text | string | JSON content. |
Return
( Values )
The values object loaded with the structure and data obtained with the JSON string.
global
_val.global() : Values
Description
Instance of type Values to store data that is only available during the execution of the HTTP request, it is useful to share data between scripts.
How To Use
// Defines that client 10 is being processed:
const global = _val.global()
global.set('clienteId', 10)
_out.json(global)
Return
( Values )
Data that is shared globally between the different scripts during the execution of the HTTP call.
init
_val.init() : Values
Description
Initializes values in a generic way, the first data to be assigned will define whether it will be list or map.
Return
( Values )
The new generic value object.
_val.init(obj: Config | Exec | Header | Req | Res | Values | DataSchema) : Values
Description
Initializes values in a generic way, the first data to be assigned will define whether it will be list or map.
Attributes
NAME | TYPE | DESCRIPTION |
---|---|---|
obj | Config | Exec | Header | Req | Res | Values | DataSchema | Object to load the newly created values object. |
Return
( Values )
The new values object starts with the data from the passed object.
_val.init(obj: java.lang.Object) : Values
Description
Initializes values in a generic way, the first data to be assigned will define whether it will be list or map.
Attributes
NAME | TYPE | DESCRIPTION |
---|---|---|
obj | java.lang.Object | Object to load the newly created values object. |
Return
( Values )
The new values object starts with the data from the passed object.
_val.init(obj: Config | Exec | Header | Req | Res | Values | DataSchema) : Values
Description
Initializes values in a generic way, the first data to be assigned will define whether it will be list or map.
Attributes
NAME | TYPE | DESCRIPTION |
---|---|---|
obj | Config | Exec | Header | Req | Res | Values | DataSchema | Object to load the newly created values object. |
Return
( Values )
The new values object starts with the data from the passed object.
is
_val.is(obj: java.lang.Object) : boolean
Description
Checks whether the object is of the value type.
Attributes
NAME | TYPE | DESCRIPTION |
---|---|---|
obj | java.lang.Object | Object to be validated if it is of the value type. |
Return
( boolean )
Result of checking whether it is of type values or not.
list
_val.list() : Values
Description
Starts a new object of values but of type list.
Return
( Values )
The new values object started as list.
_val.list(values: java.lang.Object) : java.util.List
Description
Transforms an object from values to a normal list.
Attributes
NAME | TYPE | DESCRIPTION |
---|---|---|
values | java.lang.Object | Value object in list mode. |
Return
( java.util.List )
A new normal list of items from the received value object.
_val.list(values: Values) : java.util.List
Description
Transforms an object from values to a normal list.
Attributes
NAME | TYPE | DESCRIPTION |
---|---|---|
values | Values | Value object in list mode. |
Return
( java.util.List )
A new normal list of items from the received value object.
map
_val.map() : Values
Description
Starts a new object of values but of type map.
Return
( Values )
The new values object started as map.
_val.map(values: java.lang.Object) : Config | Exec | Header | Req | Res | Values | DataSchema
Description
Transforms an object from values to a normal map.
Attributes
NAME | TYPE | DESCRIPTION |
---|---|---|
values | java.lang.Object | Value object in map mode. |
Return
( Config | Exec | Header | Req | Res | Values | DataSchema )
A new normal map with the data from the received values object.
_val.map(values: Values) : Config | Exec | Header | Req | Res | Values | DataSchema
Description
Transforms an object from values to a normal map.
Attributes
NAME | TYPE | DESCRIPTION |
---|---|---|
values | Values | Value object in map mode. |
Return
( Config | Exec | Header | Req | Res | Values | DataSchema )
A new normal map with the data from the received values object.
persistent
_val.persistent() : Values
Description
Values type instance to store data that persists in memory, that is, the data stored here are available for all HTTP requests.
How To Use
// Count kept in memory that increases with each refresh:
const persistent = _val.persistent()
persistent.set('counter', persistent.getInt('counter') + 1)
_out.json(persistent)
Return
( Values )
Data that is kept in memory and is available for all requests.
toJSON
_val.toJSON(values: java.util.List) : string
Description
Convert values to JSON.
Attributes
NAME | TYPE | DESCRIPTION |
---|---|---|
values | java.util.List | Values object to be transformed into JSON format. |
Return
( string )
String JSON with the structure and data of the values object.
_val.toJSON(values: java.util.List, htmlEscape: boolean) : string
Description
Convert values to JSON.
Attributes
NAME | TYPE | DESCRIPTION |
---|---|---|
values | java.util.List | Values object to be transformed into JSON format. |
htmlEscape | boolean | Turns on automatic HTML formatting of special characters that are in text values, useful for transforming accents. |
Return
( string )
String JSON with the structure and data of the values object.
_val.toJSON(values: java.util.List, htmlEscape: boolean, indentFactor: int) : string
Description
Convert values to JSON.
How To Use
const list = _val.list()
.add("Item 1")
.add("Item 2")
.add("Item 3")
const listString = _val.toJSON(list)
_out.println(`${listString}<br/>`)
const map = _val.map()
.set("key1", "Value 1")
.set("key2", "Value 2")
const mapString = _val.toJSON(map)
_out.println(`${mapString}<br/>`)
Attributes
NAME | TYPE | DESCRIPTION |
---|---|---|
values | java.util.List | Values object to be transformed into JSON format. |
htmlEscape | boolean | Turns on automatic HTML formatting of special characters that are in text values, useful for transforming accents. |
indentFactor | int | Number of spaces that should be used in JSON indentation. |
Return
( string )
String JSON with the structure and data of the values object.
_val.toJSON(values: java.util.List, indentFactor: int) : string
Description
Convert values to JSON.
Attributes
NAME | TYPE | DESCRIPTION |
---|---|---|
values | java.util.List | Values object to be transformed into JSON format. |
indentFactor | int | Number of spaces that should be used in JSON indentation. |
Return
( string )
String JSON with the structure and data of the values object.
_val.toJSON(values: Values) : string
Description
Convert values to JSON.
Attributes
NAME | TYPE | DESCRIPTION |
---|---|---|
values | Values | Values object to be transformed into JSON format. |
Return
( string )
String JSON with the structure and data of the values object.
_val.toJSON(values: Values, htmlEscape: boolean) : string
Description
Convert values to JSON.
Attributes
NAME | TYPE | DESCRIPTION |
---|---|---|
values | Values | Values object to be transformed into JSON format. |
htmlEscape | boolean | Turns on automatic HTML formatting of special characters that are in text values, useful for transforming accents. |
Return
( string )
String JSON with the structure and data of the values object.
_val.toJSON(values: Values, htmlEscape: boolean, indentFactor: int) : string
Description
Convert values to JSON.
How To Use
const list = _val.list()
.add("Item 1")
.add("Item 2")
.add("Item 3")
const listString = _val.toJSON(list)
_out.println(`${listString}<br/>`)
const map = _val.map()
.set("key1", "Value 1")
.set("key2", "Value 2")
const mapString = _val.toJSON(map)
_out.println(`${mapString}<br/>`)
Attributes
NAME | TYPE | DESCRIPTION |
---|---|---|
values | Values | Values object to be transformed into JSON format. |
htmlEscape | boolean | Turns on automatic HTML formatting of special characters that are in text values, useful for transforming accents. |
indentFactor | int | Number of spaces that should be used in JSON indentation. |
Return
( string )
String JSON with the structure and data of the values object.
_val.toJSON(values: Values, indentFactor: int) : string
Description
Convert values to JSON.
Attributes
NAME | TYPE | DESCRIPTION |
---|---|---|
values | Values | Values object to be transformed into JSON format. |
indentFactor | int | Number of spaces that should be used in JSON indentation. |
Return
( string )
String JSON with the structure and data of the values object.
toList
_val.toList(values: java.lang.Object) : java.util.List
Description
Transforms an object from values to a normal list.
Attributes
NAME | TYPE | DESCRIPTION |
---|---|---|
values | java.lang.Object | Value object in list mode. |
Return
( java.util.List )
A new normal list of items from the received value object.
_val.toList(values: Values) : java.util.List
Description
Transforms an object from values to a normal list.
Attributes
NAME | TYPE | DESCRIPTION |
---|---|---|
values | Values | Value object in list mode. |
Return
( java.util.List )
A new normal list of items from the received value object.
toMap
_val.toMap(values: java.lang.Object) : Config | Exec | Header | Req | Res | Values | DataSchema
Description
Transforms an object from values to a normal map.
Attributes
NAME | TYPE | DESCRIPTION |
---|---|---|
values | java.lang.Object | Value object in map mode. |
Return
( Config | Exec | Header | Req | Res | Values | DataSchema )
A new normal map with the data from the received values object.
_val.toMap(values: Values) : Config | Exec | Header | Req | Res | Values | DataSchema
Description
Transforms an object from values to a normal map.
Attributes
NAME | TYPE | DESCRIPTION |
---|---|---|
values | Values | Value object in map mode. |
Return
( Config | Exec | Header | Req | Res | Values | DataSchema )
A new normal map with the data from the received values object.