Using locize
More
Why do I get “The passed json is nested too deeply.” when consuming the API?
Sometimes while consuming the API it returns with a status code 400, “Body not valid! The passed json is nested too deeply.”
What’s the reason for this error?

The locize API generally only accepts flat json.

For example this would not be a valid body:
1
{
2
"new": {
3
"key": "default value"
4
},
5
"another": {
6
"existing": {
7
"key": "another changed value",
8
"phrase": "another value"
9
}
10
}
11
}
Copied!
this has to be sent like this:
1
{
2
"new.key": "default value",
3
"another.existing.key": "another changed value",
4
"another.existing.phrase": "another value"
5
}
Copied!

optional context (the exception):

In case you want to also save a context information for a specific translation, you can define a nested object like this:
1
{
2
"new.key": {
3
"value": "default value",
4
"context": {
5
"text": "description for this key"
6
}
7
},
8
"another.existing.key": "another changed value",
9
"another.existing.phrase": "another value"
10
}
Copied!
"default value" is now defined as nested value for the "new.key" key. And next to the "value" property there is the “context” property containing an object having a "text" property describing the context for "new.key" key.
For more information consult the API documentation.
Last modified 9mo ago