More generally, the input and output of encoding/json need not be a file at 
all.

On Tuesday, January 30, 2024 at 10:54:57 AM UTC-5 Brian Candler wrote:

> By the definition of "3.403 Text File 
> <https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap03.html#tag_03_403>"
>  
> then no, because a JSON file can have arbitrarily long lines.
>
> Note also: "Although POSIX.1-2017 does not distinguish between text files 
> and binary files (see the ISO C standard), many utilities only produce 
> predictable or meaningful output when operating on text files"
>
> Hence there's no guarantee that a line-based text processing utility like 
> grep or sed will behave meaningfully with arbitrary JSON data. Typically 
> they do work with "incomplete" lines (3.195), but not arbitrarily long ones.
>
> On Tuesday 30 January 2024 at 15:20:00 UTC Javier Marti wrote:
>
>> So, as per the link that I sent, a json file is not a text file, right? 
>> is just a file, I want to have this clear
>>
>>
>> thanks
>>
>> On Tue, Jan 30, 2024 at 3:50 PM 'Brian Candler' via golang-nuts <
>> golan...@googlegroups.com> wrote:
>>
>>> The JSON spec does not require any whitespace after the object, newline 
>>> or otherwise. And POSIX does not require that files end with a newline.
>>>
>>> Maybe you are thinking of another spec, like https://jsonlines.org/ - 
>>> but that's not part of JSON.
>>>
>>> On Tuesday 30 January 2024 at 14:16:35 UTC Xabi Martí wrote:
>>>
>>>> I'm writing a program that uses enconding/json and when writing the 
>>>> files I see that it doesn't add a newline character at the end of the 
>>>> file, 
>>>> according to 
>>>> https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap03.html#tag_03_206
>>>>  
>>>> it is supposed that a line is:
>>>>
>>>> 3.206 Line
>>>> A sequence of zero or more non- <newline> characters plus a terminating 
>>>> <newline> character.
>>>>
>>>> so, I've to add it manually? why is not POSIX compatible? 
>>>>
>>>> example:
>>>>
>>>> cat -e file.json | tail -n 2
>>>>   }$
>>>> }%
>>>>
>>>> any help? thanks!
>>>>
>>> -- 
>>> You received this message because you are subscribed to a topic in the 
>>> Google Groups "golang-nuts" group.
>>> To unsubscribe from this topic, visit 
>>> https://groups.google.com/d/topic/golang-nuts/qjxJ3Zunzfc/unsubscribe.
>>> To unsubscribe from this group and all its topics, send an email to 
>>> golang-nuts...@googlegroups.com.
>>> To view this discussion on the web visit 
>>> https://groups.google.com/d/msgid/golang-nuts/692bd65e-74f4-448a-b399-de8c38785aefn%40googlegroups.com
>>>  
>>> <https://groups.google.com/d/msgid/golang-nuts/692bd65e-74f4-448a-b399-de8c38785aefn%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/f7da4cc2-9ba2-43a2-8c82-566fbbe5b1e0n%40googlegroups.com.

Reply via email to