Skip to content

Commit 13f5225

Browse files
committed
QH tech review comment 1
1 parent 96ecdbb commit 13f5225

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

source/data-formats/extended-json.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ Extended JSON string and unmarshal the data into an instance of ``Person``:
165165
:visible: false
166166

167167
Go Struct Representation:
168-
{ObjectID("578f6fa2df35c7fbdbaed8c5") Liana Ruiz 46 569203200000 {500 Slippery Rock Road Round Rock AR} [cycling baking]}
168+
{ID:ObjectID("578f6fa2df35c7fbdbaed8c5") Name:Liana Ruiz Age:46 Birthday:569203200000 Address:{Street:500 Slippery Rock Road City:Round Rock State:AR} Hobbies:[cycling baking]}
169169

170170
Write Extended JSON
171171
-------------------
@@ -190,7 +190,7 @@ format from an instance of ``Person``:
190190
:visible: false
191191

192192
Extended JSON Representation:
193-
{"_id":{"$oid":"6865676087d421da7feaf0f2"},"name":"Matteo Carisi","age":50,"birthday":{"$date":"1975-10-30T00:00:00Z"},"address":{"street":"14a Corner Court","city":"Springfield","state":"IL"},"hobbies":["cooking","birdwatching"]}
193+
{"_id":{"$oid":"686688fa7c1a2e75405f4697"},"name":"Matteo Carisi","age":49,"birthday":{"$date":"1975-10-30T00:00:00Z"},"address":{"street":"14a Corner Court","city":"Springfield","state":"IL"},"hobbies":["cooking","birdwatching"]}
194194

195195
The second parameter to ``MarshalExtJSON()`` determines if the output
196196
string is in Canonical (Extended) format or Relaxed format. The
@@ -231,7 +231,7 @@ indentation:
231231

232232
{
233233
"_id": {
234-
"$oid": "68656b1d063ac2608439c843"
234+
"$oid": "686688fa7c1a2e75405f4697"
235235
},
236236
"name": "Matteo Carisi",
237237
"age": 49,

source/includes/data-formats/ejson.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,13 @@ func main() {
3131
// begin-unmarshal
3232
var extJsonString = "{\"_id\":{\"$oid\":\"578f6fa2df35c7fbdbaed8c5\"},\"name\":\"Liana Ruiz\",\"age\":46,\"birthday\":{\"$date\":\"1988-01-15T00:00:00Z\"},\"address\":{\"street\":\"500 Slippery Rock Road\",\"city\":\"Round Rock\",\"state\":\"AR\"},\"hobbies\":[\"cycling\", \"baking\"]}"
3333

34-
var person Person
35-
err := bson.UnmarshalExtJSON([]byte(extJsonString), false, &person)
34+
var p Person
35+
err := bson.UnmarshalExtJSON([]byte(extJsonString), false, &p)
3636
if err != nil {
3737
log.Fatal(err)
3838
}
3939

40-
fmt.Println("Go Struct Representation:\n", person)
40+
fmt.Printf("Go Struct Representation:\n%+v\n", p)
4141
// end-unmarshal
4242

4343
// begin-marshal

0 commit comments

Comments
 (0)