Writing to json to a file

I’m collecting some JSON from an end point. I can print this to screen:
fmt.Printf(“%s\n”, bodyText).

I’m struggling to figure how to write the bodyText to a file.

Any help appreciated.

If you mean that you don’t know how to open a file, I recommend checking out os.Create or os.OpenFile. If you mean how to write the data into the file, I recommend checking out fmt.Fprintln. If you mean something else, can you elaborate on what you’re struggling with?

1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.