PC SOFT

FOROS PROFESIONALES
WINDEVWEBDEV y WINDEV Mobile

Inicio → WEBDEV 2024 → [JSON] Dynamically get a specific key
[JSON] Dynamically get a specific key
Iniciado por EKoster, 11,abr. 2021 08:58 - No hay respuesta
Miembro registrado
16 mensajes
Publicado el 11,abril 2021 - 08:58
I've a process to display messages, e.g. errors, a specific way. It uses a language based json file with groups of messages. In case of errors, the message can be technical or user friendly based on a parameter passed to a function. You don't want to give user a message with no meaning to them and when debugging you want the same situation to immediately help.

So I can read my JSON file into 'oMessages' which then includes:
{
"errors": {
"default": {
"SYS-001": "User friendly text"
},
"development": {
"SYS-001": "technical text"
}
}


I've a function to get a message. It gets a few parameters "strGroup", "strType", "strCode". What I can do in for example nodejs to get the message is "oMessages[strGroup][strType][strCode]". However in webdev I seem to do it in to steps. I can only get it working if I first put in a variable "oMessages[strGroup, strType]" and then from there do "variable[strCode]".

Is there a way to do it in one go?