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 11import { NbtTag } from 'deepslate'
22import yaml from 'js-yaml'
33import { Store } from '../Store.js'
4- import { jsonToNbt , safeJsonParse } from '../Utils.js'
4+ import { jsonToNbt , message , safeJsonParse } from '../Utils.js'
55
66const INDENTS : Record < string , number | string | undefined > = {
77 '2_spaces' : 2 ,
@@ -16,7 +16,15 @@ const FORMATS: Record<string, {
1616} > = {
1717 json : {
1818 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+ } ,
2028 } ,
2129 snbt : {
2230 parse : ( s ) => JSON . stringify ( NbtTag . fromString ( s ) . toSimplifiedJson ( ) , null , 2 ) ,
You can’t perform that action at this time.
0 commit comments