File tree 2 files changed +7
-2
lines changed
2 files changed +7
-2
lines changed Original file line number Diff line number Diff line change @@ -970,7 +970,10 @@ function toJsonReplacer(key, value) {
970
970
*/
971
971
function toJson ( obj , pretty ) {
972
972
if ( typeof obj === 'undefined' ) return undefined ;
973
- return JSON . stringify ( obj , toJsonReplacer , pretty === true ? 2 : pretty ) ;
973
+ if ( ! isNumber ( pretty ) ) {
974
+ pretty = pretty ? 2 : null ;
975
+ }
976
+ return JSON . stringify ( obj , toJsonReplacer , pretty ) ;
974
977
}
975
978
976
979
Original file line number Diff line number Diff line change @@ -1189,7 +1189,7 @@ describe('angular', function() {
1189
1189
} ) ;
1190
1190
1191
1191
1192
- iit ( 'should format objects pretty' , function ( ) {
1192
+ it ( 'should format objects pretty' , function ( ) {
1193
1193
expect ( toJson ( { a : 1 , b : 2 } , true ) ) .
1194
1194
toBe ( '{\n "a": 1,\n "b": 2\n}' ) ;
1195
1195
expect ( toJson ( { a : { b : 2 } } , true ) ) .
@@ -1200,6 +1200,8 @@ describe('angular', function() {
1200
1200
toBe ( '{"a":1,"b":2}' ) ;
1201
1201
expect ( toJson ( { a : 1 , b : 2 } , 1 ) ) .
1202
1202
toBe ( '{\n "a": 1,\n "b": 2\n}' ) ;
1203
+ expect ( toJson ( { a : 1 , b : 2 } , { } ) ) .
1204
+ toBe ( '{\n "a": 1,\n "b": 2\n}' ) ;
1203
1205
} ) ;
1204
1206
1205
1207
You can’t perform that action at this time.
0 commit comments