What is a Nested JSON and how does it differ from Simple JSON?
File Extensions | .json |
API Extension | nested_json |
Import | Yes |
Export | Yes |
Pluralization supported? | Yes |
Descriptions supported? | No |
Format Options | enable_pluralization |
Nested JSON is simply a JSON file with a fairly big portion of its values being other JSON objects. Compared with Simple JSON, Nested JSON provides higher clarity in that it decouples objects into different layers, making it easier to maintain. Using Phrase, keys will be stored by separating levels with a dot. During export, all keys will be split again and rendered in the original nested JSON structure.
Code Sample
{
"boolean_key": "--- true\n",
"empty_string_translation": "",
"key_with_description": "Check it out! This key has a description! (At least in some formats)",
"key_with_line-break": "This translations contains\na line-break.",
"nested": {
"deeply": {
"key": "Wow, this key is nested even deeper."
},
"key": "This key is nested inside a namespace."
},
"null_translation": null,
"pluralized_key": {
"one": "Only one pluralization found.",
"other": "Wow, you have %s pluralizations!",
"zero": "You have no pluralization."
},
"sample_collection": [
"first item",
"second item",
"third item"
],
"simple_key": "Just a simple key with a simple message.",
"unverified_key": "This translation is not yet verified and waits for it. (In some formats we also export this status)"
}
Format Options
Identifier | enable_pluralization |
Type | boolean |
Upload | Yes |
Download | No |
Default | true |
Description | Enables detection of pluralized keys. All matching keys will be persisted as pluralized keys. |
Plural forms
This format uses named categories to identify the different plural forms of a key. The following categories are reserved for plural forms:
.zero | .one | .two | .few | .many | .other
Example key names:
inbox.messages.notification.one
inbox.messages.notification.other
This way pluralized keys can be identified, persisted and marked accordingly.
Learn more about plural forms