• Rob Pike's avatar
    encoding/json: fix handling of anonymous fields · 357e37dc
    Rob Pike authored
    The old code was incorrect and also broken. It passed the tests by accident.
    The new algorithm is:
            1) Sort the fields in order of names.
            2) For all fields with the same name, sort in increasing depth.
            3) Choose the single field with shortest depth.
    If any of the fields of a given name has a tag, do the above using
    tagged fields of that name only.
    Fixes #5245.
    
    R=iant
    CC=golang-dev
    https://golang.org/cl/8583044
    357e37dc
decode_test.go 26.1 KB