JSON Flattener

If you find this tool helpful, please share it with others

What does a flat JSON mean?

A flat JSON is a specific type of JSON file with content made up of simple key-value pairs. This format is commonly used for storing localization messages in software localization. Each key in these files represents a unique identifier of a localization message, and its value represents the translation.

Example:

{
  "common.ok": "OK",
  "common.next": "Next",
  "common.previous": "Previous",
  "page.home.title": "Welcome",
  "page.home.subtitle": "Glad to see you again"
}

What does a nested JSON mean?

A nested JSON is a specific type of JSON file characterized by its hierarchical organization of content through key-value pairs. This format is also utilized for managing localization messages within software localization. In these files, keys can encompass additional key-value pairs as their values, allowing the categorization of localization messages into broader groups.

Example:

{
  "common": {
    "ok": "OK",
    "next": "Next",
    "previous": "Previous"
  },
  "page": {
    "home": {
      "title": "Welcome",
      "subtitle": "Glad to see you again"
    }
  }
}

What are the common reasons for flattening or unflattening JSON files in software localization?

There are multiple reasons why someone might need to flatten or unflatten JSON localization files. One of the most common cases involves switching to another localization library that requires such a change. Another common scenario is the requirement to send localization files to translators; in these instances, flat structures are often preferred as they are easier to work with than nested ones, especially for non-technical people. Finally, personal preferences or the need for faster processing might also drive such a change.

What characters are commonly used as delimiters in flattening and unflattening processes?

In the process of flattening and unflattening JSON localization files, you can use any symbol as a delimiter. Yet, it's widely accepted to use a period ('.') for this purpose. The key factor to keep in mind is selecting a delimiter that doesn't hinder your ability to seamlessly switch between the two forms. For instance, if your string key names already contain underscores ('_'), choosing an underscore as your delimiter could lead to a one-way operation, since reversing the process would return a different output than the original.

Copyrights 2024 © Localizely