Practical use case for X-Flatten header?


#1

When/where does it make sense to use:

X-Flatten: true
{ 
    ...,
    "data": {
        "name": {
            "de": "Copenhagen",
            "sv": "Köpenhamn"
        },
        "population": 1400000
    }
}

https://docs.squidex.io/concepts/localization#x-flatten-header


#2

Just want to explain again what it does: Whenever you have only one value per field it flattens this field.

This is useful in two scenarios:

  1. When you have a client in javascript or typescript where you typically do not want to write deserialization code.

  2. When you use X-Languages. You can configure fallback languages in Squidex and then define in your request that you want to have German texts only. Then you will get a flat structure with the correct languages only.