English
Map
About 467 wordsAbout 2 min
2026-01-09
Map
Map - A collection type enclosed with [], containing comma-separated key-value pairs.
Summary
Define a Map:
Example:
Map map = ["a":1, "b": 2, "c":3]
```text
Map type methods:
- map.keys(): Gets all property names in the dictionary
Return type: List
Example:
```text
Map map = ["a": 1, "b": 2]
result = map.keys() // Returns: ["a", "b"]
```text
- map.size(): Returns the number of elements in the dictionary
Return type: BigDecimal
Example:
```text
Map map = ["a": 1, "b": 2]
result = map.size() // Returns: 2
```text
- map.isEmpty(): Checks if the dictionary is empty. Returns true if no key-value mappings exist; false otherwise
Return type: Boolean
Example:
```text
Map map = ["a": 1, "b": 2]
result = map.isEmpty() // Returns: false
```text
- map.remove(`<String key>`): Removes and returns the element with the specified key
Return type: Object
Example:
```text
Map map = ["a": 1, "b": 2]
map.remove("a") // Returns: 1
```text
- map.clear(): Removes all key-value pairs from the dictionary
Return type: void
Example:
```text
Map map = ["a": 1, "b": 2]
map.clear()
```text
- map.put(`<String key>`,`<Object value>`): Stores a key-value pair
Return type: void
Example:
```text
Map map = ["a": 1, "b": 2]
map.put('c', 3)
```text
- map.putIfAbsent(`<String key>`,`<Object value>`): Stores a key-value pair only if the key doesn't exist
Return type: Object
Example:
```text
Map map = ["a": 1, "b": 2]
map.putIfAbsent('a', 2) // The value of key "a" remains 1
```text
- map.containsKey(`<String key>`): Checks if the dictionary contains the specified key
Return type: Boolean
Example:
```text
Map map = ["a": 1, "b": 2]
map.containsKey("a"); // Returns: true
```text
- map.containsValue(`<Object value>`): Checks if the dictionary contains the specified value
Return type: Boolean
Example:
```text
Map map = ["a": 1, "b": 2]
map.containsValue(2); // Returns: true
```text
- map.values(): Returns a collection of all values
Return type: List
Example:
```text
Map map = ["a": 1, "b": 2]
map.values(); // Returns: [1, 2]
```text
- map.each(`<Closure closure>`): Iterates through dictionary data, passing key and value to the closure
Return type: List
Example:
```text
Map map = ["a": 1, "b": 2]
map.each {String key,value ->
log.info(key)
log.info(value)
}
```text
## Changelog
| Version | Date | Changes | Author |
| --- | --- | --- | --- |
| v1.0 | 2026-05-20 | Initial version | |
## Background
This document provides detailed information about the Map API functionality and usage, helping developers integrate relevant capabilities.
## Applicable Scenarios
Specific applicable scenarios are determined by actual business needs. Developers can select the appropriate API for integration as required.
## Prerequisites
- Access to Fxiaoke Open Platform
- Application authorization and configuration completed
- Basic knowledge of relevant business domain
## Steps
Please refer to the detailed instructions for each API.
## Notes
- Ensure prerequisites are met before calling APIs
- Pay attention to API call frequency limits
- Refer to error code documentation for exception handling
> **Compatibility:** This version currently has no deprecated or compatibility notes.