Answer the question
In order to leave comments, you need to log in
How to display data in JSOn format as strings in golang?
Hello. I'm not sure if the question is correct, but still. I receive data in JSON format that looks like this.
I accept this data, process it in a REST api with working CRUD and get this kind of output that I can interact with
. Question: how to make the output as beautiful as it was originally? Thank you in advance.
Code: https://play.golang.org/p/AMNTFim5xXI
Answer the question
In order to leave comments, you need to log in
Essentially, the output is equal to the input. Except that the input is
an array of objects {id:, userId:, title: body:}
and the output:
an array of objects {ID:, userId:, title: body:}
That is, id -> ID. Well, copy values from one structure to another structure with other fields. When json.Marshal
you get a new array.
how to make the output as beautiful as the original?This is redundant: for the computer, this only leads to additional overhead.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question