I could not figure it out how to add comments line in the translation file of easy localization package for flutter. The file is in Json format. This can be useful in large file.
Asked
Active
Viewed 81 times
1
-
Hey, you can't leave comments in JSON format. So this is not possible – Muhammadakbar Rafikov Feb 01 '23 at 00:14
1 Answers
2
Can I add a comment in JSON? No, JSON is a data-only format. Comments in the form //, #, or /* */, which are used in popular programming languages, are not allowed in JSON. You can add comments to JSON as custom JSON elements that will hold your comments, but these elements will still be data.
way1.
JSONC Example with JavaScript-style Comments
{ /*
This is a multi-line
comment in a JSONC.
*/
"Id":1 // This is a single-line comment in JSONC.
}
way2.
Multiple JSON Comments Example
{
"Id": 1,
"//first_comment": "The first JSON comment.",
"//second_comment": "The second JSON comment."
}

Javatar
- 131
- 6