-
Notifications
You must be signed in to change notification settings - Fork 13
WDL ~ Comparing options for parsers for JSON files
As we are making the switch to using JSON objects rather than YAML, this document will discuss the options available to use for parsing JSON objects.
Currently, we have a YAML parser implemented in parser.c in the parse_game() function. This YAML parser SHOULD work with JSON objects, as JSON is a subset of YAML. Multiple sources confirm this: https://stackoverflow.com/questions/24608600/is-it-safe-to-parse-json-with-yaml-load https://www.json2yaml.com/yaml-vs-json
However, there are parsers that are specific to Json, cJSON and Json-c, that seem to be strong options to use instead of the YAML parser we currently have. To see whether using a Json specific parser would work better than using the YAML parser we currently have and to see which Json specific parser would be better if we decide to use one, I looked at various sources to compare the parsers:
From http://www.discoversdk.com/compare/cjson-vs-json_c:
“cJson:
- It's a single file of C, and a single header file.
- cJSON doesn't make any assumptions about what order you create things in. You can attach the objects, as above, and later add children to each of those objects.
- Open Source & Easy to use.
Json-c
- parse JSON strings into the C representation of JSON objects.
- Open Source & Easy to use.”
I mention this because cJson isn’t too complex as it contains its functions in a single file as shown in: https://github.com/DaveGamble/cJSON/blob/master/cJSON.h, so the implementation of this parser in parse_game() won’t be hard enough to be a reason to stop us from using it. Json-c, https://github.com/json-c/json-c, is also mentioned as easy to use so changing the YAML parser to Json-c shouldn’t be too difficult.
From https://stackoverflow.com/questions/1726802/what-is-the-difference-between-yaml-and-json Mentions that there is a speed difference in using json over yaml. However, this doesn’t mention if this difference is due to the YAML file format or the difference is due between using a JSON specific parser and the YAML parser. I have also found many answers like the answer from within this link that YAML is better than JSON because of serialization. However, this is irrelevant because: We are using the JSON files for parsing and not serialization as we don’t plan on converting objects that are in the doc obj type in the Chiventure repository back into the JSON format. The serialization answer is based on YAML/JSON objects instead of the parser itself.
However, https://stackoverflow.com/questions/2451732/how-is-it-that-json-serialization-is-so-much-faster-than-yaml-serialization-in-p shows that there is a speed difference between YAML and Json-c in serialization. However, the top answer in this post mentions that “The YAML parsers are comparatively complex, leading to increased overheads.” compared to Json-c. So this suggests that YAML parsers are slower than Json specific parsers by magnitudes (as shown in the speed of each parser in the question), which could be important if we plan on expanding chiventure to be a MUCH longer game than it is right now.
So in conclusion, using a Json specific parser is better than using the current YAML parser we currently have. Between which parser to use, Json-c seems to be the better choice, as cJSON doesn't have any significant advantages that will outweigh Json-c's ability to parse JSON strings into C's representation of JSON objects as we will only use Json-c for parsing. This will allow us to parse the string easier as it allows us to get information from JSON objects to use in our obj type in libobj.
-
Action Management
-
Battles
- Design Document
- Text Based Combat in Other Games
- User Stories
- Wishlist
- Battle Planning 2022
- Battle User Stories Review 2022
- Structs in Other Modules Related to Battles 2022
- Stat Changes Design Document
- Run Function Design Document
- CLI Integration Design Document
- Move Changes Design Document
- Unstubbing Stubs Design Document
- Battle Items and Equipment Design Document
- Battle Item Stats
- Battles Demo Design Document
- Battles Testing Moves, Items, and Equipment Design Document
- Sound integration with battle (design document)
-
Custom Actions
-
Custom Scripts
-
DSL
-
CLI
-
Enhanced CLI
-
Game-State
-
Graphics
- Design Plan
- Design document for integrating split screen graphics with chiventure
- GDL (Graphical Description Language)
- Graphics Sandbox
- Design Document for NPC Graphics and Dialogue
- Feature Wishlist (Spring 2021)
- Installing and Building raylib on a VM
- LibSDL Research
- Module Interactions
- Working with Raylib and SSH
- raylib
- GDL
-
Linking the Libzip and Json C to chiventure on CSIL machines
-
Lua
-
NPC
- Dependencies: Player class, Open world, Battle
- Action Documentation
- Design Document for NPC Generation in Openworld
- Design and Planning
- Establishing Dependencies
- Implementation of Custom Scripts
- Independent Feature: NPC Movement Design Document
- Player Interaction Design and Planning
- Dialogue
- Design Document for NPC Dialogue and Action Implementation
- Loading NPCs from WDL Files
- NPC Battle Integration Design Document
- NPC Battle Integration Changes Design Document
-
Open World
- Autogeneration and Game State
- Deciding an integration approach
- Designing approach for static integration into chiventure
- Feature Wishlist
- Generation Module Design layout
- Potential connections to the rest of chiventure
- Single Room Generation Module Design
- Source Document
- User Stories
- World Generation Algorithm Plan
- Loading OpenWorld Attribute from WDL
-
Player Class
-
Player
-
Quests
-
Rooms
-
Skill Trees
- Avoiding soft locks in skill tree integration
- Components of Exemplary Skill Trees
- Design Document and Interface Guide
- Environment interactions based on skill characteristics
- Integrating complex skill (combined, random, sequential, etc.) implementation
- Integration of a Leveling System
- Potential Integration with existing WDL
- Research on game balancing in regards to skill trees
- Research on skill tree support in modern day game engines
- SkillTree Wiki Summary
- Skilltree "effect" implementation and roadmap
- Summary of md doc file for skilltrees
- Design ideas in connection to other features
- Summary of Skill Tree Integration 2022
- The Difficulty of the Reading the World
- Complex Skills Summary
-
Sound
-
Stats
-
WDL