@@ -1233,89 +1233,19 @@ func TestMarshal(t *testing.T) {
1233
1233
}` ,
1234
1234
}, {
1235
1235
name : jsontest .Name ("Structs/SpaceAfterColonAndComma" ),
1236
- opts : []Options {
1237
- jsontext .SpaceAfterColon (true ),
1238
- jsontext .SpaceAfterComma (true ),
1239
- },
1240
- in : structAll {
1241
- Bool : true ,
1242
- String : "hello" ,
1243
- Bytes : []byte {1 , 2 , 3 },
1244
- Int : - 64 ,
1245
- Uint : + 64 ,
1246
- Float : 3.14159 ,
1247
- Map : map [string ]string {"key" : "value" },
1248
- StructScalars : structScalars {
1249
- Bool : true ,
1250
- String : "hello" ,
1251
- Bytes : []byte {1 , 2 , 3 },
1252
- Int : - 64 ,
1253
- Uint : + 64 ,
1254
- Float : 3.14159 ,
1255
- },
1256
- StructMaps : structMaps {
1257
- MapBool : map [string ]bool {"" : true },
1258
- MapString : map [string ]string {"" : "hello" },
1259
- MapBytes : map [string ][]byte {"" : {1 , 2 , 3 }},
1260
- MapInt : map [string ]int64 {"" : - 64 },
1261
- MapUint : map [string ]uint64 {"" : + 64 },
1262
- MapFloat : map [string ]float64 {"" : 3.14159 },
1263
- },
1264
- StructSlices : structSlices {
1265
- SliceBool : []bool {true },
1266
- SliceString : []string {"hello" },
1267
- SliceBytes : [][]byte {{1 , 2 , 3 }},
1268
- SliceInt : []int64 {- 64 },
1269
- SliceUint : []uint64 {+ 64 },
1270
- SliceFloat : []float64 {3.14159 },
1271
- },
1272
- Slice : []string {"fizz" , "buzz" },
1273
- Array : [1 ]string {"goodbye" },
1274
- Pointer : new (structAll ),
1275
- Interface : (* structAll )(nil ),
1276
- },
1277
- want : `{"Bool": true, "String": "hello", "Bytes": "AQID", "Int": -64, "Uint": 64, "Float": 3.14159, "Map": {"key": "value"}, "StructScalars": {"Bool": true, "String": "hello", "Bytes": "AQID", "Int": -64, "Uint": 64, "Float": 3.14159}, "StructMaps": {"MapBool": {"": true}, "MapString": {"": "hello"}, "MapBytes": {"": "AQID"}, "MapInt": {"": -64}, "MapUint": {"": 64}, "MapFloat": {"": 3.14159}}, "StructSlices": {"SliceBool": [true], "SliceString": ["hello"], "SliceBytes": ["AQID"], "SliceInt": [-64], "SliceUint": [64], "SliceFloat": [3.14159]}, "Slice": ["fizz", "buzz"], "Array": ["goodbye"], "Pointer": {"Bool": false, "String": "", "Bytes": "", "Int": 0, "Uint": 0, "Float": 0, "Map": {}, "StructScalars": {"Bool": false, "String": "", "Bytes": "", "Int": 0, "Uint": 0, "Float": 0}, "StructMaps": {"MapBool": {}, "MapString": {}, "MapBytes": {}, "MapInt": {}, "MapUint": {}, "MapFloat": {}}, "StructSlices": {"SliceBool": [], "SliceString": [], "SliceBytes": [], "SliceInt": [], "SliceUint": [], "SliceFloat": []}, "Slice": [], "Array": [""], "Pointer": null, "Interface": null}, "Interface": null}` ,
1236
+ opts : []Options {jsontext .SpaceAfterColon (true ), jsontext .SpaceAfterComma (true )},
1237
+ in : structOmitZeroAll {Int : 1 , Uint : 1 },
1238
+ want : `{"Int": 1, "Uint": 1}` ,
1239
+ }, {
1240
+ name : jsontest .Name ("Structs/SpaceAfterColon" ),
1241
+ opts : []Options {jsontext .SpaceAfterColon (true )},
1242
+ in : structOmitZeroAll {Int : 1 , Uint : 1 },
1243
+ want : `{"Int": 1,"Uint": 1}` ,
1278
1244
}, {
1279
1245
name : jsontest .Name ("Structs/SpaceAfterComma" ),
1280
1246
opts : []Options {jsontext .SpaceAfterComma (true )},
1281
- in : structAll {
1282
- Bool : true ,
1283
- String : "hello" ,
1284
- Bytes : []byte {1 , 2 , 3 },
1285
- Int : - 64 ,
1286
- Uint : + 64 ,
1287
- Float : 3.14159 ,
1288
- Map : map [string ]string {"key" : "value" },
1289
- StructScalars : structScalars {
1290
- Bool : true ,
1291
- String : "hello" ,
1292
- Bytes : []byte {1 , 2 , 3 },
1293
- Int : - 64 ,
1294
- Uint : + 64 ,
1295
- Float : 3.14159 ,
1296
- },
1297
- StructMaps : structMaps {
1298
- MapBool : map [string ]bool {"" : true },
1299
- MapString : map [string ]string {"" : "hello" },
1300
- MapBytes : map [string ][]byte {"" : {1 , 2 , 3 }},
1301
- MapInt : map [string ]int64 {"" : - 64 },
1302
- MapUint : map [string ]uint64 {"" : + 64 },
1303
- MapFloat : map [string ]float64 {"" : 3.14159 },
1304
- },
1305
- StructSlices : structSlices {
1306
- SliceBool : []bool {true },
1307
- SliceString : []string {"hello" },
1308
- SliceBytes : [][]byte {{1 , 2 , 3 }},
1309
- SliceInt : []int64 {- 64 },
1310
- SliceUint : []uint64 {+ 64 },
1311
- SliceFloat : []float64 {3.14159 },
1312
- },
1313
- Slice : []string {"fizz" , "buzz" },
1314
- Array : [1 ]string {"goodbye" },
1315
- Pointer : new (structAll ),
1316
- Interface : (* structAll )(nil ),
1317
- },
1318
- want : `{"Bool":true, "String":"hello", "Bytes":"AQID", "Int":-64, "Uint":64, "Float":3.14159, "Map":{"key":"value"}, "StructScalars":{"Bool":true, "String":"hello", "Bytes":"AQID", "Int":-64, "Uint":64, "Float":3.14159}, "StructMaps":{"MapBool":{"":true}, "MapString":{"":"hello"}, "MapBytes":{"":"AQID"}, "MapInt":{"":-64}, "MapUint":{"":64}, "MapFloat":{"":3.14159}}, "StructSlices":{"SliceBool":[true], "SliceString":["hello"], "SliceBytes":["AQID"], "SliceInt":[-64], "SliceUint":[64], "SliceFloat":[3.14159]}, "Slice":["fizz", "buzz"], "Array":["goodbye"], "Pointer":{"Bool":false, "String":"", "Bytes":"", "Int":0, "Uint":0, "Float":0, "Map":{}, "StructScalars":{"Bool":false, "String":"", "Bytes":"", "Int":0, "Uint":0, "Float":0}, "StructMaps":{"MapBool":{}, "MapString":{}, "MapBytes":{}, "MapInt":{}, "MapUint":{}, "MapFloat":{}}, "StructSlices":{"SliceBool":[], "SliceString":[], "SliceBytes":[], "SliceInt":[], "SliceUint":[], "SliceFloat":[]}, "Slice":[], "Array":[""], "Pointer":null, "Interface":null}, "Interface":null}` ,
1247
+ in : structOmitZeroAll {Int : 1 , Uint : 1 , Slice : []string {"a" , "b" }},
1248
+ want : `{"Int":1, "Uint":1, "Slice":["a", "b"]}` ,
1319
1249
}, {
1320
1250
name : jsontest .Name ("Structs/Stringified" ),
1321
1251
opts : []Options {jsontext .Multiline (true )},
0 commit comments