Skip to content

Commit

Permalink
Updated read json due to object object error (#1043)
Browse files Browse the repository at this point in the history
* Updated with 2 things

Added create primitive mod

Added seperator mod

* Updated these with lint

* Updated these with lint

* Updated canvas_create_primitive_MOD.js

* Added json_read_MOD

added json_write_MOD.js

* Added json_read_MOD

added json_write_MOD.js

* Added json_read_MOD

added json_write_MOD.js

* Added json_read_MOD

added json_write_MOD.js

* Fixed lint issue I hope

* Fixed lint issue I hope

* Fixed prettier issues

Fixed linting issues inside json write

Fixed issue with canvas paint not using cases

* Added json random

* **Changelog**

* Fixed json_random_MOD.js meta data

* Fixed json_read_MOD.js meta data

* Added json_check_MOD.json

* **Changelog**

* Fixed json_random_MOD.js meta data

* Fixed json_read_MOD.js meta data

* Added json_check_MOD.json

* **Changelog**

* Fixed json_random_MOD.js meta data

* Fixed json_read_MOD.js meta data

* Added json_check_MOD.json

* **Changelog**

* Fixed json_random_MOD.js meta data

* Fixed json_read_MOD.js meta data

* Added json_check_MOD.json

* **Changelog**

* added nested check

* **Changelog**

* removed error handler

* **Changelog**

* removed error handler

* **Changelog**

* Updated all json actions to make them more clear

* **Changelog**

* Created a mod version of get_list_length_MOD.js this one only returns a number for the list length and not a list like 1,2,3. this also makes it so if the list is empty or is not a list it will be undefined

* **Changelog**

* Created a mod version of get_list_length_MOD.js this one only returns a number for the list length and not a list like 1,2,3. this also makes it so if the list is empty or is not a list it will be undefined

* Fixed Title

* Added console event action

* Added console event action

* Added console event action

* RE added the convert packages

* Fixed json read
  • Loading branch information
thekingofspace authored Jun 23, 2024
1 parent 98f6e2d commit 2c9a087
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions actions/json_read_MOD.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,14 +82,17 @@ module.exports = {
const titleData = jsonData.find((item) => item.Title === title);
if (!titleData) throw new Error('Title not found');

if (contentTitle.includes('/')) {
if (contentTitle && contentTitle.includes('/')) {
const contentKeys = contentTitle.split('/');
result = {};
let nestedValue = titleData;
for (const key of contentKeys) {
if (titleData[key] !== undefined) {
result[key] = titleData[key];
if (nestedValue[key] !== undefined) {
nestedValue = nestedValue[key];
} else {
throw new Error(`Content key '${key}' not found`);
}
}
result = nestedValue;
} else {
if (titleData[contentTitle] === undefined) throw new Error('Content Title not found');
result = titleData[contentTitle];
Expand Down

0 comments on commit 2c9a087

Please sign in to comment.