Is there a Go equivalent equivalent to Perm's Dumper () method in Data :: Dumper?

I looked at a very similar heading ( Is there C equivalent to the Dumper () Perls method in Data :: Dumper? ) With respect to C equivalent Data::Dumper::Dumper();. I have a similar question for Go language.

I am a Perl Zealot by profession and am a pro-gamer and use Data::Dumpersimilar offspring literally hundreds of times a day. I started learning Go because it looks like a funny and interesting language, something that will get me out of the Perl routine I'm in, opening my eyes to new ways of doing things ... One of the things I really want is something like:

fmt.Println(dump.Dumper(decoded_json))

to see the resulting data structure, for example, Data::Dumperturn JSON into a hash array. Having seen this in Go, I will help you understand how to create and work with data. Something like this will be considered a highlight in the light of my Go training.

Contrary to the statements made in column C , I believe that we can write this, and since I will pass the Dumper to Println, after compilation, no matter what JSON line or XML page I transmit and decode. I should be able to see the result of decoding in a similar state of the Dumper ... So, does anything like that exist? or maybe some pointers to doing something similar?

+5
source share
3 answers

, . -.

, encoding/json, , , . , . , Data:: Dumper perl, , , , . go, , . , , , , .

, , :

+10

I am not familiar with Perl and Dumper, but from what I understand from your message and the associated C message (and the function name itself!), It displays the contents of the data structure.

You can do this using the verb% v fmt package . I assume that your JSON data is decoded into a structure or map. Using fmt.Printf("%v", json_obj), print the values, and% + v will add the names of the fields (for the structure - there is no difference if its a map,% v will display both keys and values), and% # v also displays information about the type.

+5
source

All Articles