JSON Tree Support *or* Subcategories

Issue #2 new
Martin Heß created an issue

my output for day localisation is something like that:

{
  "date.sTerm": "Datum",
  "date.pTerm": "Daten",

  "date.day.sTerm": "Tag",
  "date.day.pTerm": "Tage",

  "date.day_short.0": "So",
  "date.day_short.1": "Mo",
  "date.day_short.2": "Di",
  "date.day_short.3": "Mi",
  "date.day_short.4": "Do",
  "date.day_short.5": "Fr",
  "date.day_short.6": "Sa",

  "date.day_long.0": "Sonntag",
  "date.day_long.1": "Montag",
  "date.day_long.2": "Dienstag",
  "date.day_long.3": "Mittwoch",
  "date.day_long.4": "Donnerstag",
  "date.day_long.5": "Freitag",
  "date.day_long.6": "Samstag",

  "date.month.sTerm": "Monat",
  "date.month.pTerm": "Monate",

  "date.month_long.0": "Januar",
  "date.month_long.1": "Februar",
  "date.month_long.2": "März",
  "date.month_long.3": "April",
  "date.month_long.4": "Mai",
  "date.month_long.5": "Juni",
  "date.month_long.6": "Juli",
  "date.month_long.7": "August",
  "date.month_long.8": "September",
  "date.month_long.9": "Oktober",
  "date.month_long.10": "November",
  "date.month_long.11": "Dezember",

  "date.month_short.0": "Jan",
  "date.month_short.1": "Feb",
  "date.month_short.2": "Mär",
  "date.month_short.3": "Apr",
  "date.month_short.4": "Mai",
  "date.month_short.5": "Jun",
  "date.month_short.6": "Jul",
  "date.month_short.7": "Aug",
  "date.month_short.8": "Sep",
  "date.month_short.9": "Okt",
  "date.month_short.10": "Nov",
  "date.month_short.11": "Dez"
}

it would be perfect if other file structures like:

{
    "date": {
        "day": {
            "sTerm": "Tag",
            "pTerm": "Tage",
            "short": {
                "0": "So",
                "1": "Mo",
                "2": "Di",
                "3": "Mi",
                "4": "Do",
                "5": "Fr",
                "6": "Sa"
            },
            "long": {
                "0": "Sonntag",
                "1": "Montag",
                "2": "Dienstag",
                "3": "Mittwoch",
                "4": "Donnerstag",
                "5": "Freitag",
                "6": "Samstag"
            }
        },
        "sTerm": "Datum",
        "pTerm": "Daten",
        "month": {
            "sTerm": "Monat",
            "pTerm": "Monate",
            "long": {
                "0": "Januar",
                "1": "Februar",
                "2": "März",
                "3": "April",
                "4": "Mai",
                "5": "Juni",
                "6": "Juli",
                "7": "August",
                "8": "September",
                "9": "Oktober",
                "10": "November",
                "11": "Dezember"
            },      
            "short": {
                "0": "Jan",
                "1": "Feb",
                "2": "Mär",
                "3": "Apr",
                "4": "Mai",
                "5": "Jun",
                "6": "Jul",
                "7": "Aug",
                "8": "Sep",
                "9": "Okt",
                "10": "Nov",
                "11": "Dez"
            }
        }
    }
}

So that every "Category" can contain Subcategories and Terms/Phrases and would be perfectly sorted by

key in alphabetical order

or

by value type (string before object) and key alphabetical.

Comments (4)

  1. Martin Heß reporter
    • edited description

    WARNING:

    Keep in mind that some people on Stackoverflow already using your tool and changing this can break the assignment by key. So an optional setting to get the new and the old output is required.

    Dot separated Sting:

    a = { "b.c.d": "text" } ==>> Object {b.c.d: "text"}

    a["b.c.d"] returns "text"

    a.b.c.d breaks with Uncaught TypeError: Cannot read property 'c' of undefined

    JSON Object Tree:

    a = { "b": { "c": { "d": "text" } } } ==>> Object {b: Object}

    a.b.c.d returns "text"

    a["b.c.d"] returns undefined

  2. Nick Heijmink Account Deactivated

    This is a thing I need for my project. We are using hierarchical json files for our project which sadly does not work with this tool :(

  3. Log in to comment