PC SOFT

PROFESSIONAL NEWSGROUPS
WINDEVWEBDEV and WINDEV Mobile

Home → WEBDEV 2024 → [JSON] Dynamically get a specific key
[JSON] Dynamically get a specific key
Started by EKoster, Apr., 11 2021 8:58 AM - No answer
Registered member
16 messages
Posted on April, 11 2021 - 8:58 AM
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?