Why JSON files sometimes fail after Save?

Discuss any general programming issues here
Flinx
Posts: 342
Joined: Sun Feb 14, 2021 9:54 am
Location: Germany

Re: Why JSON files sometimes fail after Save?

Post by Flinx »

By the way, the Seek line can be removed from the position where the BOM was found. Initially, I had the Seek(id, 0) directly after ReadBytes, which I then moved down, but then I forgot to delete the Seek(id, 3). The file cursor is already at position 3 there.
User avatar
airsoftsoftwair
Posts: 5830
Joined: Fri Feb 12, 2010 2:33 pm
Location: Germany
Contact:

Re: Why JSON files sometimes fail after Save?

Post by airsoftsoftwair »

Flinx wrote: Sat Sep 13, 2025 5:41 pm I think this is a bug.
Actually not. The BOM character is illegal in JSON so it's not a bug. See here.
Flinx
Posts: 342
Joined: Sun Feb 14, 2021 9:54 am
Location: Germany

Re: Why JSON files sometimes fail after Save?

Post by Flinx »

airsoftsoftwair wrote: Sun Sep 14, 2025 12:46 pm Actually not. The BOM character is illegal in JSON so it's not a bug.
Ah, interesting. But it probably won't help much to tell the developers of Visual Studio Code that...
Bugala
Posts: 1390
Joined: Sun Feb 14, 2010 7:11 pm

Re: Why JSON files sometimes fail after Save?

Post by Bugala »

Also, as I mentioned, this problem occurs when I am saving with Hollywood IDE as well.

It appears, that by default Hollywood IDE is saving as UTF-8 BOM.

Can you change Hollywood IDE by default to use UTF-8 only, or would that affect Hollywood scripts? Point being, that it is bit confusing that you cant use Hollywood IDE out of the box to do something as standard as JSON, without first manually changing the settings to save files as plain UTF-8 instead of the BOM version like it seems to be doing at least in my case, or is this something that windows automatically configures instead of IDE doing it?
Flinx
Posts: 342
Joined: Sun Feb 14, 2021 9:54 am
Location: Germany

Re: Why JSON files sometimes fail after Save?

Post by Flinx »

Hmm, Bugala, JSON is a data interchange format. That means it is intended to be written by programs and read by parsers that have been specifically developed for this purpose. The fact that it can be read and written in an editor makes life easier for developers (at least if they know what they're doing), but that doesn't mean it's a completely normal procedure.
So I think we really shouldn't demand support for a private way of working from an editor that is intended as a universal tool for all kinds of text, or in the case of the IDE, specifically for Hollywood scripts.
jalih
Posts: 280
Joined: Fri Jun 18, 2010 8:08 pm
Location: Finland

Re: Why JSON files sometimes fail after Save?

Post by jalih »

Flinx wrote: Tue Sep 16, 2025 8:55 am So I think we really shouldn't demand support for a private way of working from an editor that is intended as a universal tool for all kinds of text, or in the case of the IDE, specifically for Hollywood scripts.
It's normal procedure to edit JSON with text editor or any other tool. BOM is not needed or recommended to be used with UTF-8, so it makes no sense for a text editor to add a BOM to UTF-8 text.
Bugala
Posts: 1390
Joined: Sun Feb 14, 2010 7:11 pm

Re: Why JSON files sometimes fail after Save?

Post by Bugala »

Flinx wrote: Tue Sep 16, 2025 8:55 am Hmm, Bugala, JSON is a data interchange format. That means it is intended to be written by programs and read by parsers that have been specifically developed for this purpose. The fact that it can be read and written in an editor makes life easier for developers (at least if they know what they're doing), but that doesn't mean it's a completely normal procedure.
So I think we really shouldn't demand support for a private way of working from an editor that is intended as a universal tool for all kinds of text, or in the case of the IDE, specifically for Hollywood scripts.
Ah, appears I have misunderstood JSONs point then. Thought it was like HTML, that it is meant to be an easy way to create these datatables and doable on any text editor basically. Makes sense it would have these restrictions when you put it that way.
User avatar
airsoftsoftwair
Posts: 5830
Joined: Fri Feb 12, 2010 2:33 pm
Location: Germany
Contact:

Re: Why JSON files sometimes fail after Save?

Post by airsoftsoftwair »

Flinx wrote: Sun Sep 14, 2025 1:37 pm Interesting. But it probably won't help much to tell the developers of Visual Studio Code that...
Well, not the first time MS programmers don't care about specifications ;)
Bugala wrote: Sun Sep 14, 2025 8:57 pm Can you change Hollywood IDE by default to use UTF-8 only, or would that affect Hollywood scripts?
You can do it yourself. In the IDE settings you can select whether files should be saved as UTF-8, UTF-8 with BOM or ISO 8859-1.
Post Reply