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

JSON: Add more ACE #470

Open
2 tasks done
XHXIAIEIN opened this issue Feb 16, 2025 · 6 comments
Open
2 tasks done

JSON: Add more ACE #470

XHXIAIEIN opened this issue Feb 16, 2025 · 6 comments

Comments

@XHXIAIEIN
Copy link

Reviewed guidelines

  • I have read and understand the suggestion guidelines

Checked for duplicate suggestions

  • I checked for existing similar suggestions

Summary

JSON is a very useful and powerful, but C3's vanilla JSON plugin missing some of necessary ACEs, which often causes us to get stuck in some places.

Possible workarounds or alternatives

You need to add a lot of extra steps, or use js to complete it. For experienced developers, this is pretty easy. But when we want to introduce the vanilla JSON plugin to newbies, this puts us in an awkward situation.

Proposed solution

I will add it below

Why is this idea important?

It is very useful for some data-driven games.

Additional remarks

No response

@XHXIAIEIN
Copy link
Author

JSON expression: JSON.CurIndex

We need an expression like loopindex for use in a For each loop of a JSON object.

JSON.CurIndex

Currently, it is necessary to Add a new local variable externally to record it, which is very cumbersome.

Snipaste_2024-01-08_21-25-53

@XHXIAIEIN
Copy link
Author

XHXIAIEIN commented Feb 16, 2025

JSON expression: JSON.KeyCount

Dictionary has the useful KeyCount expression, but the JSON object does not have it.

Add JSON.KeyCount(path) expressions like Object.keys(path).length. Return the number of keys in Path.

This is very useful for statistics and UI lists. For example, if you want to create objects based on the number of keys in the path. And assign index numbers to these objects.

Currently, you have to access the path via JSON: For each and create a local variable outside to count, which is very cumbersome.

@XHXIAIEIN
Copy link
Author

XHXIAIEIN commented Feb 16, 2025

JSON action: Stop Loop

We also need Stop Loop action.

When Loop in this structure, When you find a matching value, need a 'Stop loop' so that it does not traverse the entire file.

@XHXIAIEIN
Copy link
Author

JSON condition: 'is Empty'

is Empty condition can be used to check whether the object at the path is empty.This is still very useful. For example, it is used to detect the quantity of UI, inventory, item, Achievement, Status Entry, etc.

"data": []
"data": {}
"data": ""

Snipaste_2024-01-08_21-55-01

@XHXIAIEIN
Copy link
Author

JSON expression: GetDefault

Dictionary has the useful GetDefault() expression, but the JSON object does not have it.

I would appreciate if JSON would also get this functionality as it is very handy.

GetDefault(key, valueIfMissing)

Return the value stored for a key, but if it is missing, return a different value instead. For example Dictionary.GetDefault("name", "guest") will return the value of the key "name" if it exists, otherwise it will return the string "guest".

@XHXIAIEIN
Copy link
Author

JSON action: For Each(Ordered)

order any JSON array or object by their keys and/or by their values (ascending/descending), For example, it is very useful when you want to add sorting functionality to the UI.

Snipaste_2024-01-09_17-08-46

for example:

[
    {"id": "7001", "name": "banana"},
    {"id": "1002", "name": "carrot"},
    {"id": "2024", "name": "apple"}
]

Order By "id"

{"id": "1002", "name": "carrot"},
{"id": "2024", "name": "apple"}
{"id": "7001", "name": "banana"},

Order By "id.name"

{"id": "2024", "name": "apple"}
{"id": "7001", "name": "banana"},
{"id": "1002", "name": "carrot"},

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant