Grokking Advanced Go
Vote

0% completed

​

encoding json v2

The program below gives one Order to two JSON packages, and then gives one line of JSON text to the same two packages. The results differ in both cases.

Output:

v1: {"id":1001,"customer":"Ada \u0026 Lin","items":null} v2: {"id":1001,"customer":"Ada & Lin","items":[]} v1: 1002 Lin <nil> v2: 0 Ada jsontext: duplicate object member name "customer"

The first package accepts ID for the field tagged id, and the later customer value replaces the earlier one with no error. The second package matches names exactly and rejects the duplicate

.....

.....

.....

Like the course? Get enrolled and start learning!

Reading Progress

0%


Vote for new content