As responses coming from upstream server, because my application acting as
proxy server and it will not have  visibility of the fields of the
responses coming.
So, think appending the characters to meet JSON format is only way. Am I
right assuming so?

On Mon, Jan 20, 2020 at 4:07 PM Tamás Gulácsi <tgulacs...@gmail.com> wrote:

> Please define "better".
>
> For complexity and speed, appending "[", inserting ",", and appending "]"
> at the end is the simplest and fastest solution.
>
> If you want to check for syntax and completeness, then you should
> unmarshal, append, and then marshal again.
> But if not needed, it's just complexity and resource hog.
>
> You can hide it in a function/library, but anyway, any solution would do
> one of the two solutions specified here.
> So it will be either "hacky" or "bloat".
>
> At least when the "hacky" solution is in plain sight, you'll know where to
> check first when syntax errors araise :-)
>
> Tamás
>
> 2020. január 20., hétfő 10:19:26 UTC+1 időpontban pc a következőt írta:
>>
>> Yes, I also need to put '[' at first and ']' at last position. But I was
>> checking if there is any better way to do it. I was even having question
>> how can someone make it better without unmarshalling JSON and remarshalling
>> merged object.
>>
>>
>> On Mon, Jan 20, 2020 at 4:12 AM Tamás Gulácsi <tgula...@gmail.com> wrote:
>>
>>> Just put the missing [,] chars wher it's required with buf.WriteByte.
>>>
>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "golang-nuts" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to golan...@googlegroups.com.
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/golang-nuts/00bb4351-e400-46a6-aec1-05124a966410%40googlegroups.com
>>> .
>>>
>> --
> You received this message because you are subscribed to the Google Groups
> "golang-nuts" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to golang-nuts+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/golang-nuts/71b5beb8-31e3-4894-9575-ee3c04514e2a%40googlegroups.com
> <https://groups.google.com/d/msgid/golang-nuts/71b5beb8-31e3-4894-9575-ee3c04514e2a%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/CAP3P0bzaFeUNnNLbiM34B_rVALpD%3DECJcR_nVvhXk1ZLyh6%3DyA%40mail.gmail.com.

Reply via email to