Skip to content

Refactor code to use json.Unmarshal instead of json.Decoder

Refactor code to use json.Unmarshal instead of json.Decoder.

json.Decoder designed to receive JSON streams, and can silence invalid JSON data. There is more information in the following article: https://ahmet.im/blog/golang-json-decoder-pitfalls/

Performance-wise json.Decoder can use less memory, but dependency files we're scanning aren't too big. There is another article on comparison json.Unmarshal and json.Decoder: https://blog.devgenius.io/to-unmarshal-or-to-decode-json-processing-in-go-explained-e92fab5b648f

Same idea probably valid for xml and yaml packages.

Edited by Vitali Tatarintev