skJson

Addon skJson 3.0.2-IO

  • Welcome to skUnity!

    Welcome to skUnity! This is a forum where members of the Skript community can communicate and interact. Skript Resource Creators can post their Resources for all to see and use.

    If you haven't done so already, feel free to join our official Discord server to expand your level of interaction with the comminuty!

    Now, what are you waiting for? Join the community now!

Fix broken save json %string% For example, the operations for linking a file were error, fix (save json "..."), that will handle in the newest Skript version as World.
Fix cache - cache will be keep until reload/restart your server



Full Changelog: https://github.com/SkJsonTeam/skJson/compare/3.0.1...3.0.2-IO
Change from Effect to AsyncEffect to process asynchronous operations exactly as expected. For example, the operations for linking a file were error

Full Changelog: https://github.com/SkJsonTeam/skJson/compare/3.0.0...3.0.1
Major updates to SkJson (breaking changes!)

Internal API has been changed for the latest version only Skript 2.8+ is supported, also requests have been changed, now they are more skript friendly from
Code:
on script load:
    async make POST request to "https://dummyjson.com/carts/add":
        headers: "Content-Type: application/json"
        content: json from text "{userId: 1, products: [{id: 1, quantity: 1}, {id: 50, [quote][/quote]quantity: 2}]}"
        save incorrect response: true
        lenient: true
        save:
            content: {-content}
            headers: {-header}
            status code: {-code}
            url: {-url}
At @Requests
Code:
    set {_request} to prepare new GET request on "https://raw.githubusercontent.com/SkJsonTeam/skJson/main/skjson.jsonn"
    set {_request}'s request content to @{"A": true}
    set {_request}'s headers to @{"Content-Type": "application/json+vhd"}
    send prepared {_request}

    if response status is "OK":
        send response status code of {_request}
        send response content of {_request}
        send response status code of {_request}
        send response headers of {_request}
webhooks will be updated in future versions..
Supplied
- https://skjson.xyz/documentation/latest#expression-IndexListObject
- https://skjson.xyz/documentation/latest#expression-AllJsonInFolder

Modified algorithm for parsing a string to a Key Structure. Faster file processing. Fixed working with files.. now files are locked only if really used.

Finished single line literal json.

What's Changed
* 3.0.0 pre by @SkJsonTeam in https://github.com/SkJsonTeam/skJson/pull/83


Full Changelog: https://github.com/SkJsonTeam/skJson/compare/2.9.7...3.0.0
AllJsonInFolder
Code:
on script load:
    send all json files in dir "./plugins/Skript/JSONS"

    loop all json files in dir "./plugins/Skript/JSONS":
        send loop-file
        send json from file loop-file

that will allowed to you, loop through directory and get the path of the given file and also the json from it.

Full Changelog: https://github.com/SkJsonTeam/skJson/compare/2.9.6...2.9.7
we changed from using NBT-Items to SKBee because Nbt was not working properly.

What's Changed
* Fix nbt using skbee by @cooffeeRequired in https://github.com/SkJsonTeam/skJson/pull/81


Full Changelog: https://github.com/SkJsonTeam/skJson/compare/2.9.4...2.9.6
Fixing some small issues, non-async request was fixed.
Requests
This release fixes a serious bug in requests and webhooks that asynchronous startup did not work and blocked the main thread...
! It has also been removed for now on complete until I find out exactly why it blocked the main thread as well
Code:
on load:
    make new GET request to "https://dummyjson.com/products/2" and store it in {_data}:
       content: {_content}
       status code: {_code}
    execute {_data} and wait
    send {_content}
When you can create and save your request. and for example use Script-reflect to further work with it or directly in the section you can specify where to save it. The section is imspired by Skript-reflect!
Webhook
added for discord username and avatar-url

What's Changed
* Async await requests by @SkJsonTeam in https://github.com/SkJsonTeam/skJson/pull/76
* Update skjson.json by @SkJsonTeam in https://github.com/SkJsonTeam/skJson/pull/77


Full Changelog: https://github.com/SkJsonTeam/skJson/compare/2.9.3...2.9.4
Working with Json within a literal has been added,
as well as improved asynchronous processing for the Request class.
Example of Request

If there is a return in on complete then skjson will recognize that you want to wait for a response, RECOMMENDATION: use this only when you know the server is available.
also in on complete you can execute any code because this section is so called executable

Code:
function test(i: number) :: object:
    async make POST request to "http://localhost:3000/?id=%{_id}%":
        save incorrect response: true
        lenient: true
        save:
            content: {_content}
        on complete:
            return {_content}
local function clear():
    loop 100 times:
        send " " to console

command test <number>:
    trigger:
        loop arg-1 times:
            wait 1 tick
            set {_t} to test(loop-number)
            send {_t}

Literal JSON
you don't need to use % before and after the expresseme because SkJson parser recognizes it and passes it to the Script parser. the same goes for strings, if you want to escape use classic json escape for example `\", \r, \t, \n"
Code:
on script load:
    set {_X} to @{"json": true}
    set {[i]json} to @{id: 10, something: "Test", var: {[/i]X}, string: "\nthis \"new\" Thing"}
    send {_json}

You must enable both of these features in the settings.

Config
Code:
  # Beta features
  features:
    # That feature will you allow use tld. literal string for e.g.
    # @{userId: 1, products: [{id: {[i]i}, quantity: 1}, {id: {[/i]j}, quantity: 2}]}
    # Inside the Literal string you don't need use a % for evaluate variables or expressions.
    # Also,you don't need to use string escape as like "", you can basically json string escape for e.g.
    # @{test: "This is \"New\" String"}
    # So the literal start always with @ and then continue a with a JSON
    literal-parsing-single-line: true
    
    # This Feature allows you to immediately get the value from the async run of the request.
    # For e.g.
    # function test(i: number) :: object:
    #    async make POST request to "https://dummyjson.com/carts/add":
    #        headers: @{Content-Type: "Application/json"}
    #        headers: json from text "{Content-Type: 'application/json'}"
    #        content: json from text "{userId: 1, products: [{id: %{_i}%, quantity: 1}, {id: 50, quantity: 2}]}"
    #        save incorrect response: true
    #        lenient: true
    #        save:
    #            content: {_content}
    #        on complete:
    #            return {_content}
    #
    # command test <number>:
    #    trigger:
    #        send test(arg-1)
    force-async-return: true

What's Changed
* Main http handing by @cooffeeRequired in https://github.com/SkJsonTeam/skJson/pull/75


Full Changelog: https://github.com/SkJsonTeam/skJson/compare/2.9.1...2.9.3
SkJson 2.9.1

Fixes

16:52 - 24.09
1. Pretty print
2. Command skJson about

Full Changelog: https://github.com/SkJsonTeam/skJson/compare/2.9...2.9.1
SkJson 2.9

It's finally here, we have finally seen a fully stable version of SkJson, i.e. version 2.9 which introduced SkJson in the biggest steam, A lot of changes have been made from the ground up.

We have created our own documentation page for SkJson, on this page we will be able to post thready where you can share your code https://www.skjson.xyz/snippests, we also have documentation for both versions with examples. The documentation is automatically updated! Let's get started on the changes!

Condition
* Json file exist
* Json file is cached
* Json file is listening
* Json has value/key
* Json is empty
* Type of json

Expressions
* Count value/key in the Json.
* Get cached json
* Get index of key/value in (ListObject)
* Literals
* Loops
* New Json
* Pretty print
* Size of json object/array
* Skript variable to Json
* Value of JSON

Effects
* Change json file contents
* Json (virtual) storage [lon-linked]
* Json to Skript variable list
* JsonWatcher - Start/Stop listening to file
* Link json file with defined cache
* New json file with/out content
* Save cached json to file
* Unlink or unload json file from cache
* Write content to json file
* link and load all json files from given folder

Events
* watcher[/i]save]Json watcher save

Sections
* Http requests (All methods includes)
* Webhooks (Discord/Web)

Functions
* b64 (Decoding from String to B64)
* skjson_getdelim]skjsongtdelim (Get your defined delimiter)

Types
* JSON
* JSON-WEBHOOK
* JSON-ENUM ( WEBREQUEST METHODS )

Changers
* JSON-ARRAY
* JSON-OBJECT


Resolved Issues.
* #69
* #65
* #64
* #63
* #62
* #61
* #60
* #59
* #58
* #45
* #41
* #39
* #38

Special thanks...
I would like to thank everyone who participated in testing and trying out all sorts of features, and especially I would like to thank those who reported all the bugs!

Thank again! (@MinecraftNight4, @yhdev7935, @ExCorde, @Nocky, @welormit, @Envizar, @RedstoneGamer54)



What's Changed
* Update main from 2.8.6 to 2.9 by @SkJsonTeam in https://github.com/SkJsonTeam/skJson/pull/70


Full Changelog: https://github.com/SkJsonTeam/skJson/compare/2.8.6...2.9