JSON Objects
The jsn values represent JSON objects with native support for nested properties, lists, and utility methods.
Declaration
Section titled “Declaration”jsn persona = { nombre: "Ana", edad: 28, activo: verdadero}Property Access
Section titled “Property Access”Dot Notation
Section titled “Dot Notation”texto nombre = persona.nombrenumero peso = persona.datos_personales.pesoBracket Notation
Section titled “Bracket Notation”texto nombre = persona["nombre"]texto especial = datos["clave con espacios"]JSON Methods
Section titled “JSON Methods”Key Verification
Section titled “Key Verification”| Method | Description | Returns |
|---|---|---|
contiene_clave(clave) | Checks if property exists | log |
Get Keys and Values
Section titled “Get Keys and Values”| Method | Description | Returns |
|---|---|---|
claves() | List of first-level keys | lista<texto> |
valores() | List of first-level values | lista |
Modify Properties
Section titled “Modify Properties”| Method | Description |
|---|---|
establecer(clave, valor) | Assign or create a property |
eliminar(clave) | Delete a property and return its value |
Merge Objects
Section titled “Merge Objects”| Method | Description |
|---|---|
fusionar(otro_json) | Combine properties (existing ones are overwritten) |
Serialization
Section titled “Serialization”| Method | Description |
|---|---|
texto() | Serialize to compact JSON |
texto_formateado() | Serialize with readable indentation |
Conversion from Text
Section titled “Conversion from Text”texto json_texto = '{"nombre":"Ana","edad":25}'jsn var persona = json_texto.jsn()Best Practices
Section titled “Best Practices”- Declare with
varJSON objects you need to modify. - Use
contiene_clave()before accessing properties that might not exist. - Validate external JSON with
intentar/capturarwhen parsing strings. - Use
texto_formateado()for debugging and readable logs.