File tree Expand file tree Collapse file tree 3 files changed +14
-10
lines changed
examples/json5-trailing-comma-formatter Expand file tree Collapse file tree 3 files changed +14
-10
lines changed Original file line number Diff line number Diff line change @@ -29,12 +29,12 @@ output
2929// My Document
3030{
3131 breakfast: [
32- bacon,
33- eggs,
34- spam, // <-- a trailing comma will be added here
32+ ' bacon' ,
33+ ' eggs' ,
34+ ' spam' , // <-- a trailing comma will be added here
3535 ],
3636 objekt: {
37- nested: value, // <-- and here
37+ nested: " value" , // <-- and here
3838 }, // <--- and here
3939}
4040
Original file line number Diff line number Diff line change @@ -86,12 +86,12 @@ fn test() {
8686 let expected = String :: from ( r#"// My Document
8787{
8888 breakfast: [
89- bacon,
90- eggs,
91- spam, // <-- a trailing comma will be added here
89+ ' bacon' ,
90+ ' eggs' ,
91+ ' spam' , // <-- a trailing comma will be added here
9292 ],
9393 objekt: {
94- nested: value, // <-- and here
94+ nested: " value" , // <-- and here
9595 }, // <--- and here
9696}"# ) ;
9797 assert_eq ! ( res, expected)
Original file line number Diff line number Diff line change @@ -286,8 +286,12 @@ impl JSONValue {
286286 JSONValue :: NaN => { String :: from ( "Nan" ) }
287287 JSONValue :: Hexadecimal ( s) => { s. clone ( ) }
288288 JSONValue :: Bool ( b) => b. to_string ( ) ,
289- JSONValue :: DoubleQuotedString ( s) => { s. clone ( ) }
290- JSONValue :: SingleQuotedString ( s) => { s. clone ( ) }
289+ JSONValue :: DoubleQuotedString ( s) => {
290+ format ! ( "\" {s}\" " )
291+ }
292+ JSONValue :: SingleQuotedString ( s) => {
293+ format ! ( "'{s}'" )
294+ }
291295 JSONValue :: Unary { operator, value} => {
292296 format ! ( "{operator}{value}" )
293297 }
You can’t perform that action at this time.
0 commit comments