File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -75,21 +75,16 @@ function toDisplay(v: any): string {
7575 return JSON .stringify (v );
7676}
7777
78- function isValidJson(raw : string ): boolean {
79- if (! raw .trim ()) return true ;
78+ function fromDisplay(raw : string ): any {
79+ const trimmed = raw .trim ();
80+ if (! trimmed ) return ' ' ;
8081 try {
81- JSON .parse (raw .trim ());
82- return true ;
82+ return JSON .parse (trimmed );
8383 } catch {
84- return false ;
84+ return trimmed ;
8585 }
8686}
8787
88- function fromDisplay(raw : string ): any {
89- if (! raw .trim ()) return ' ' ;
90- return JSON .parse (raw .trim ());
91- }
92-
9388function toPairs(json : any ): Pair [] {
9489 let obj: any ;
9590 if (typeof json === ' string' ) {
@@ -116,10 +111,6 @@ function getError(): string | null {
116111 if (new Set (keys ).size < keys .length ) {
117112 return ' Duplicate keys are not allowed' ;
118113 }
119- const badIndex = pairs .value .findIndex ((p : Pair ) => p .key .trim () && ! isValidJson (p .value ));
120- if (badIndex !== - 1 ) {
121- return ` Row ${badIndex + 1 }: value is not valid JSON ` ;
122- }
123114 return null ;
124115}
125116
You can’t perform that action at this time.
0 commit comments