Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PROCESS JSON COMMAND - New Features #3341

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

jetrotal
Copy link
Contributor

@jetrotal jetrotal commented Jan 23, 2025

The Operations were updated to:

0: GET
1: SET
2: GET LENGTH
3: GET KEYS
4: GET VAR TYPE

There are also new Flags:

  • Extract data from json path - similar to how stringvars extracts \v[1], \t[2], etc.
  • Prettify json - to make its output easier to read.

@Ghabry
Copy link
Member

Ghabry commented Jan 23, 2025

We had this discussion before: Exceptions (try-catch) are not enabled on emscripten to reduce binary size.

(and our homebrew platforms but they do not have JSON support enabled so you do not see them failing here)

The Operations were updated to:

0: GET
1: SET
2: GET LENGTH
3: GET KEYS
4: GET VAR TYPE

There are also new Flags:
 - Extract data from json path - similar to how stringvars extracts.
 - Prettify json - to make its output easier to read.

Update json_helper.cpp
@jetrotal
Copy link
Contributor Author

Sorry about the confusion, Now the code is way closer to how initially was

@jetrotal
Copy link
Contributor Author

jetrotal commented Jan 23, 2025

I found some OOB crashes from the older implementation,
When trying to reach /lists/data/6 from:

"lists": {
            "length": 5,
            "data": [{
                    "id": "MAP TYPE",
                    "length": 7,
                    "values": ["EasyRPG World", "EasyRPG Exterior", "EasyRPG Interior", "EasyRPG Dungeon", "EasyRPG Ship", "Uncanny World", "Danny's House"],
                    "chipset_files": ["EasyRPG_World", "EasyRPG_Exterior", "easyRPG_interiorB", "EasyRPG_Dungeon", "EasyRPG_Ship", "EasyRPG+gfragger_mkt_CCBY", "EasyRPG+kotatsuAkira_Interior_CC0"],
                    "tileset_locations": [1531, 1535, 1534, 1533, 1532, 523, 524],
                    "current": 0
                },
                {
                    "id": "TILES LAYER",
                    "length": 3,
                    "values": ["LOWER", "UPPER", "EVENTS"],
                    "current": 0
                },
                {
                    "id": "DRAW AUTOTILES",
                    "length": 2,
                    "values": ["YES", "NO"],
                    "current": 0
                },
                {
                    "id": "MAP PANORAMA",
                    "length": 4,
                    "values": ["[OFF]", "A", "B", "C"],
                    "current": 0
                },
                {
                    "id": "BACKGROUND MUSIC",
                    "length": 4,
                    "values": ["[OFF]", "A", "B", "C"],
                    "current": 0
                }
            ]
        },

I thought about adding some error messages, but those messages could conflict with cases such as:

[
[-6,-6,-6,-6,-6,-6,-6,-6,-6,-6],
[6,-6,-6,null,-6,-6,-6],[-6,-6,-6,-6,-6,-6,-6,null,null,null,-6,-6],
[-6,6,-6,null,-6,-6,-6,-6,-6,-6,-6,-6],
[-6,6,6,null,14,14,14,-6,14,14,14,-6,14,14,14,null,14,14,14,6],
[6,6,6,null,null,14,6,null,14,null,null,null,14,-6,-6,-6,-6,14]
]

where I wanted to have null values to fast walk through a list of map tiles.

@Ghabry Ghabry added this to the 0.8.1 milestone Jan 24, 2025
…lohmann::ordered_json

this can break for loops, and it's a weird extra step when processing json data
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants