File tree Expand file tree Collapse file tree 1 file changed +10
-2
lines changed Expand file tree Collapse file tree 1 file changed +10
-2
lines changed Original file line number Diff line number Diff line change 1
1
import { NbtTag } from 'deepslate'
2
2
import yaml from 'js-yaml'
3
3
import { Store } from '../Store.js'
4
- import { jsonToNbt , safeJsonParse } from '../Utils.js'
4
+ import { jsonToNbt , message , safeJsonParse } from '../Utils.js'
5
5
6
6
const INDENTS : Record < string , number | string | undefined > = {
7
7
'2_spaces' : 2 ,
@@ -16,7 +16,15 @@ const FORMATS: Record<string, {
16
16
} > = {
17
17
json : {
18
18
parse : ( s ) => s ,
19
- stringify : ( s ) => s ,
19
+ stringify : ( s , i ) => {
20
+ try {
21
+ const data = JSON . parse ( s )
22
+ return JSON . stringify ( data , null , i )
23
+ } catch ( e ) {
24
+ console . warn ( `Failed to format JSON output. Falling back to source. ${ message ( e ) } ` )
25
+ return s
26
+ }
27
+ } ,
20
28
} ,
21
29
snbt : {
22
30
parse : ( s ) => JSON . stringify ( NbtTag . fromString ( s ) . toSimplifiedJson ( ) , null , 2 ) ,
You can’t perform that action at this time.
0 commit comments