Introducción a HOCON¶
HOCON (Human-Optimized Config Object Notation) is an easy-to-use configuration format. It is used by Sponge and
individual plugins utilizing SpongeAPI to store important data, such as configuration or player data. HOCON files
typically use the suffix .conf
.
Componentes¶
- una
key
es una cadena que precede a un valor - un
value
es una cadena, número, objeto, matriz o booleano que sigue a unakey
- un
key-value separator
separa las claves de los valores, y puede ser:
o=
- un
comment
tiene el prefijo# `` o ``//
, que típicamente sirve para proporcionar comentarios o instrucciones
Ejemplo:
yellow-thing: "Sponge"
En este ejemplo, la key
es yellow-thing
, el value
es `` Sponge``, y el key-value separator
es ``: ``.
Trabajando con HOCON¶
HOCON es más flexible que el formato JSON (JavaScript Object Notation) ya que hay varias formas válidas de escribir HOCON. A continuación hay dos ejemplos válidos de HOCON.
Ejemplo #1:
player: {
name: "Steve",
level: 30
}
Ejemplo #2:
player {
name = "Steve"
level = 30
}
In practice, it is best to follow the formatting conventions of the HOCON configuration you are editing. When editing a HOCON configuration for Sponge or an individual plugin utilizing SpongeAPI, the values are likely the only thing you will be changing unless otherwise specified.
Depurando su configuración¶
Si una configuración HOCON parece no estar funcionando, aquí hay algunos consejos.
- Las llaves deben ser balanceadas
- Las comillas deben ser balanceadas
- Las claves duplicadas que aparezcan más tarde toman prioridad