Reputation: 1
I have a json file created in javascript that includes a script as in the following simplified example:
script1.json
{
"name": "script1",
... <many other properties>
"script": "date as timestamp,\n\t\tid as integer,\n\t\tfirst_name as string,\n\t\tlast_name as string"
}
The script can get very long, and sometimes I have to look at these files and it is unreadble. As such I'm considering storing the script as an array as follows, simply treating \n
as new array item and \t
as some number of spaces
script1-new.json
{
"name": "script1",
... <many other properties>
"script": ["date as timestamp,",
" id as integer,",
" first_name as string,",
" last_name as string"]
}
Is there any better way to display this sort of string in a readable format in json? Is there any best practice for doing this sort of conversion from string -> array
and vice versa in javascript?
Upvotes: 0
Views: 23