jquery.i18n icon indicating copy to clipboard operation
jquery.i18n copied to clipboard

JSON Object in Object

Open fellipejsousa opened this issue 8 years ago โ€ข 3 comments
trafficstars

Friends library has support for objects inside objects because my script is criticizing: Uncaught TypeError: message.indexOf is not a function


example json:

{
    "en": {
        "appname-title": "Example Application",
        "appname-sub-title": "An example application with jquery.i18n",
        "appname-header-introduction": "Introduction",
         "example": {
                "appname-title": "Example Application",
               "appname-sub-title": "An example application with jquery.i18n"
        },
        "appname-about": "About this application",
        "appname-footer": "Footer text"
        },
    "ml": {
        "appname-title": "เด…เดชเตเดฒเดฟเด•เตเด•เต‡เดทเดจเตโ€ เด‰เดฆเดพเดนเดฐเดฃเด‚",
        "appname-sub-title": "jquery.i18n เด‰เดชเดฏเต‹เด—เดฟเดšเตเดšเตเดณเตเดณ เด…เดชเตเดฒเดฟเด•เตเด•เต‡เดทเดจเตโ€ เด‰เดฆเดพเดนเดฐเดฃเด‚",
        "appname-header-introduction": "เด†เดฎเตเด–เด‚",
         "example": {
                "appname-title": "Example Application",
               "appname-sub-title": "An example application with jquery.i18n"
        },
        "appname-about": "เดˆ เด…เดชเตเดฒเดฟเด•เตเด•เต‡เดทเดจเต†เดชเตเดชเดฑเตเดฑเดฟ",
        "appname-footer": "เด…เดŸเดฟเด•เตเด•เตเดฑเดฟเดชเตเดชเตเต"
    }
}
}
```

fellipejsousa avatar Jan 06 '17 14:01 fellipejsousa

Same issue !

ghost avatar Sep 17 '18 13:09 ghost

Me to... How can i call an object in object, like content.title

SossenSystems avatar Apr 04 '20 19:04 SossenSystems

The error message "Uncaught TypeError: message.indexOf is not a function" is thrown when you try to use the indexOf() method on a variable that is not a string. It seems like you are trying to use this method on an object. The Friends library does support objects inside objects. You can access the nested object by using dot notation or bracket notation. Here's an example of how you can access the nested object:

var json = {
    "en": {
        "appname-title": "Example Application",
        "appname-sub-title": "An example application with jquery.i18n",
        "appname-header-introduction": "Introduction",
         "example": {
                "appname-title": "Example Application",
               "appname-sub-title": "An example application with jquery.i18n"
        },
        "appname-about": "About this application",
        "appname-footer": "Footer text"
        },
    "ml": {
        "appname-title": "เด…เดชเตเดฒเดฟเด•เตเด•เต‡เดทเดจเตโ€ เด‰เดฆเดพเดนเดฐเดฃเด‚",
        "appname-sub-title": "jquery.i18n เด‰เดชเดฏเต‹เด—เดฟเดšเตเดšเตเดณเตเดณ เด…เดชเตเดฒเดฟเด•เตเด•เต‡เดทเดจเตโ€ เด‰เดฆเดพเดนเดฐเดฃเด‚",
        "appname-header-introduction": "เด†เดฎเตเด–เด‚",
         "example": {
                "appname-title": "Example Application",
               "appname-sub-title": "An example application with jquery.i18n"
        },
        "appname-about": "เดˆ เด…เดชเตเดฒเดฟเด•เตเด•เต‡เดทเดจเต†เดชเตเดชเดฑเตเดฑเดฟ",
        "appname-footer": "เด…เดŸเดฟเด•เตเด•เตเดฑเดฟเดชเตเดชเตเต"
    }
};

console.log(json.en.example["appname-title"]); // Output: Example Application
console.log(json.ml["appname-footer"]); // Output: เด…เดŸเดฟเด•เตเด•เตเดฑเดฟเดชเตเดชเตเต

Hrithik248 avatar Jul 12 '23 08:07 Hrithik248