From 9c32e038e7e30bd423efc61921bf01b730648823 Mon Sep 17 00:00:00 2001 From: hjusforgues Date: Fri, 1 Jul 2016 18:26:23 +0700 Subject: [PATCH] Add a test case for issue #27 --- tests/basic_test.go | 1 + tests/data.go | 30 ++++++++++++++++++++++++++++++ 2 files changed, 31 insertions(+) diff --git a/tests/basic_test.go b/tests/basic_test.go index 255005b..f6fdc92 100644 --- a/tests/basic_test.go +++ b/tests/basic_test.go @@ -31,6 +31,7 @@ var testCases = []struct { {&unexportedStructValue, unexportedStructString}, {&excludedFieldValue, excludedFieldString}, {&mapsValue, mapsString}, + {&deepNestValue, deepNestString}, } func TestMarshal(t *testing.T) { diff --git a/tests/data.go b/tests/data.go index 510c3a3..d0e1e7a 100644 --- a/tests/data.go +++ b/tests/data.go @@ -436,6 +436,36 @@ var mapsString = `{` + `"CustomMap":{"c":"d"}` + `}` +type DeepNest struct { + SliceMap map[Str][]Str + MapSlice []map[Str]Str +} + +var deepNestValue = DeepNest{ + SliceMap: map[Str][]Str{ + "testSliceMap1": []Str{ + "0", + "1", + }, + "testSliceMap2": nil, + }, + MapSlice: []map[Str]Str{ + map[Str]Str{ + "testMapSlice1": "someValue", + }, + }, +} + +var deepNestString = `{` + + `"SliceMap":{` + + `"testSliceMap1":["0","1"],` + + `"testSliceMap2":[]` + + `},` + + `"MapSlice":[` + + `{"testMapSlice1":"someValue"}` + + `]` + + `}` + type RequiredOptionalStruct struct { FirstName string `json:"first_name,required"` Lastname string `json:"last_name"`