Using vue-i18n, to use the < i18n > tag in a .vue file, how to format the JSON in it

The

project uses vue-i18n, tags like this in the .vue file. I use node to extract the json from < i18n > in all the .vue files into a json file. After the translator has translated it, the translator writes it back to the .vue with node, and then there is no formatting information and becomes a line

.
<i18n>
{
  "CN": {
    "hello":""
  },
  "EN": {
    "hello":"hi"
  }
}
</i18n>

after node is written:

<i18n>
{"CN": {"hello":""},"EN": {"hello":"hi"}}
</i18n>

how can I format this piece of code


has found a solution. When node is written, JSON.stringify () is called to serialize the object into a string, and stringify receives the third parameter, which is used to format the output.

Menu