Expose JSON Parser

Remember, just because you request it, that doesn't mean you'll get it.

Moderator: GZDoom Developers

Expose JSON Parser

Postby Major Cooke » Mon Nov 25, 2019 10:54 am

Some threads have expressed that using a JSON parser from GZDoom itself would be far better than to create one in ZScript.

Now, I can't say what difference it would make but I imagine not needing to create a parser in ZScript certainly is a start.

Regardless, having some form of parser would be beneficial overall. At least this way, we don't have to worry about checking for updates on other mod libraries in the event bugs crop up - simply updating GZDoom alone will be better.
User avatar
Major Cooke
QZDoom Maintenance Team
 
Joined: 28 Jan 2007

Re: Expose JSON Parser

Postby Nash » Thu Oct 21, 2021 10:18 am

Someone has already made a JSON parser library so I'm not sure if this still needs to be added in the engine.
User avatar
Nash
AKA Nash Muhandes! Twitter/Facebook/Youtube: nashmuhandes
 
 
 
Joined: 27 Oct 2003
Location: Kuala Lumpur, Malaysia
Twitch ID: nashmuhandes
Github ID: nashmuhandes

Re: Expose JSON Parser

Postby Graf Zahl » Thu Oct 21, 2021 10:43 am

That would be magnitudes slower and less efficient, though.
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
 
Joined: 19 Jul 2003
Location: Germany

Re: Expose JSON Parser

Postby Apeirogon » Thu Oct 21, 2021 10:50 am

YAML is better, for modding purposes, IMO since its more user friendly.
User avatar
Apeirogon
I have a strange sense of humour
 
Joined: 12 Jun 2017

Re: Expose JSON Parser

Postby Graf Zahl » Thu Oct 21, 2021 11:33 am

Nobody asked you for that opinion.
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
 
Joined: 19 Jul 2003
Location: Germany

Re: Expose JSON Parser

Postby Redneckerz » Sat Oct 23, 2021 5:41 am

Graf Zahl wrote:Nobody asked you for that opinion.

Its also a redundant opinion as far as i understand - The wikipage for YAML says the following:

It uses both Python-style indentation to indicate nesting, and a more compact format that uses [...] for lists and {...} for maps[1] thus JSON files are valid YAML 1.2.[2]

So a JSON parser will have to read JSON files that are already YAML-compliant.
User avatar
Redneckerz
To it's ports i may have seen
Spotlight Team
 
Joined: 25 Nov 2019
Discord: Redneckerz#8399
Operating System: Windows 10/8.1/8/201x 64-bit
Graphics Processor: Intel (Modern GZDoom)

Re: Expose JSON Parser

Postby Rachael » Sat Oct 23, 2021 6:15 am

GZDoom already uses JSON and there's no reason to switch unless there's actually a reason to switch. One random person's desire for YAML does not constitute nor justify that switch. I think Graf was merely annoyed because the way the post was worded is quite reminiscent of someone looking to argue that "their" desired standard is better, which would be no better than the stupid and ridiculous "my distro is better" wars that sometimes flare up (or at least, used to flare up pretty often) in some of the more heavily Linux-focused spaces. Why is any other distro (or in this case, YAML vs JSON) better than what you have when the one you have serves your needs just fine? It's simply unnecessary work for what is ultimately a bit of passion from someone who is not actually responsible for the way that the source port runs.

Of course, I could be misreading the post, but that's how it came on, to me.
User avatar
Rachael
Admin
 
Joined: 13 Jan 2004
Discord: Rachael#3767
Twitch ID: madamerachelle
Github ID: madame-rachelle
Operating System: Debian-like Linux (Debian, Ubuntu, Mint, etc) 64-bit
OS Test Version: No (Using Stable Public Version)
Graphics Processor: nVidia with Vulkan support

Re: Expose JSON Parser

Postby Gutawer » Sun Oct 24, 2021 8:51 am

Personally I certainly would not ever want YAML in gzdoom, anyway. It's very overcomplicated (by some counts the language has 63 ways to write a multi line string) and its direct object deserialisation feature has caused many implementations of YAML to be fundamentally insecure and open to ACE. And especially since gzdoom already uses json it would make no sense to introduce YAML as a ZScript-usable format before json anyway, and beyond that this feature request was clearly made with the knowledge that this would just be an export without additional libraries anyway - clearly the request here was not as a modding format but as a way for mods to distribute and unpack data without writing their own parser or writing it directly as ZScript.
User avatar
Gutawer
User Accounts Assistant
 
Joined: 16 Apr 2016
Discord: Gutawer#3431

Re: Expose JSON Parser

Postby Graf Zahl » Sun Oct 24, 2021 9:20 am

IMO the entire concept behind YAML is a contradiction in terms: It wants to be a 'human readable' 'data deserialization' language.

The former will inevitably be defined rather laxly while the latter by necessity needs to obey to a strict syntax to the letter to be robust.
There's simply no way such a thing that wants to combine these two can be foolproof.
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
 
Joined: 19 Jul 2003
Location: Germany

Re: Expose JSON Parser

Postby Major Cooke » Thu Nov 04, 2021 1:14 am

Gutawer wrote:clearly the request here was not as a modding format but as a way for mods to distribute and unpack data without writing their own parser or writing it directly as ZScript.


This. I'm interested in setting up custom shop prices and descriptions so getting this exported would mean official support in the event I have trouble with it.
While I want to give it a try, I'm not sure where to start at and what all needs to be included. I also don't know if any safeguards are needed.
User avatar
Major Cooke
QZDoom Maintenance Team
 
Joined: 28 Jan 2007

Re: Expose JSON Parser

Postby Rachael » Thu Nov 04, 2021 1:23 am

I imagine it would be the same as the file reader. In fact, if you take a look at it, it should give you some idea what needs to be done and how to do it. So I would look at that, for a starting point.

You can then copy some of the definitions over, changing and adapting it to the JSON parser.

As for the safeguards, simply making everything read-only should be sufficient, as far as I know. You won't need to scope it, I don't think. Whatever the file reader has, should be sufficient of a safeguard for the JSON parser. Just don't export any methods that allow for writing savegames and what not.
User avatar
Rachael
Admin
 
Joined: 13 Jan 2004
Discord: Rachael#3767
Twitch ID: madamerachelle
Github ID: madame-rachelle
Operating System: Debian-like Linux (Debian, Ubuntu, Mint, etc) 64-bit
OS Test Version: No (Using Stable Public Version)
Graphics Processor: nVidia with Vulkan support

Re: Expose JSON Parser

Postby Graf Zahl » Thu Nov 04, 2021 1:51 am

Exposing the file reader should be relatively simple. All it needs to expose is a method to open a lump from the file system or some local memory array and the common seek/read... functions.

JSON is a bit trickier as some of the language clashes with the type safety rules which will inevitably result in a less user-friendly interface than what C++ can do. I've already seen this in Java where JSON libraries tend to be extremely clunky.
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
 
Joined: 19 Jul 2003
Location: Germany

Re: Expose JSON Parser

Postby Major Cooke » Thu Nov 04, 2021 9:11 am

This reminds me... The ability to read from a lump I've heard had a problem where it would only read from the most recent file pack. I.e. if someone made a custom lump, the lump reader (or however it's done currently) would overwrite all other lumps in the previous files if there's multiples.

Does the file reader itself have the ability to open up files via some form of iterator for all files currently open and present for the mod? Or will there need to be some sort of special handling for that?
User avatar
Major Cooke
QZDoom Maintenance Team
 
Joined: 28 Jan 2007

Re: Expose JSON Parser

Postby Graf Zahl » Thu Nov 04, 2021 9:35 am

You can iterate over all same-named lumps (short name only) with Wads.FindLump.
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
 
Joined: 19 Jul 2003
Location: Germany

Re: Expose JSON Parser

Postby Marisa Kirisame » Thu Nov 04, 2021 12:27 pm

The fact that it's for short names only sounds like a problem.
User avatar
Marisa Kirisame
ZScript Crimester
 
 
 
Joined: 08 Feb 2008
Location: Vigo, Galicia
Discord: 霧雨魔理沙#1666
Twitch ID: MarisaDOOM
Github ID: OrdinaryMagician
Operating System: Other Linux 64-bit
OS Test Version: No (Using Stable Public Version)
Graphics Processor: nVidia with Vulkan support

Next

Return to Feature Suggestions

Who is online

Users browsing this forum: No registered users and 0 guests