✔Zkopírováno
You can check if the json file already exists or not.
[skJson] json [file] %string% exists [skJson] json [file] %string% does(n't| not) exist
command FileExists:
trigger
set {_json} to json from string "{'A': [{'B': {}}, false, true, 10, 20, 22.22, 'A']}" if json file "plugins/test/main.json" already exists
2.8.0 - performance & clean
Check if the file for given id is cached
[skJson] json %string% is (load|linked) [skJson] json %string% is(n't| not) (load|linked)
on load:
send true if json "test" is linked
2.8.0 - performance & clean
Check if the file for given id is listening via JsonWatcher
json %string% is listen json %string% is(n't| not) listen
on load:
if json "test" is listen:
send true
2.8.0 - performance & clean
You can check if the inserted keys or values already in your specified json
[skJson] %json% has [:directly] (:value|:key)[s] %objects% [skJson] %json% does(n't| not) have [:directly] (:value|:key)[s] %objects%
on script load:
set {_json} to json from string "{'test5': [1], 'test6': ['key', 'key2', 'key3']}"
if {_json} has keys "test5", "test6", "A":
send true
2.8.0
You can check if the json empty
[skJson] json(-| )element %json% is empty [skJson] json(-| )element %json% is(n't| not) empty
Command jsonIsEmpty
trigger
set {_json} to json from text "{}"
send true if json element {_json} is empty
2.8.0 - performance & clean
You can get type of given Json.
[skJson] type of %json% (is|=) (1:primitive|2:json object|3:json array) [skJson] type of %json% (is(n't| not)|!=) (1:primitive|2:json object|3:json array)
set {_j} to json from "{data: {}}"
if type of {_j} is json object
2.7
The new documentation you will find here: click here
A very general effect that can change many json array. The json object can be only add/set/remove/removeAll
[skJson] json (list|array) [%string%] in %jsons% [skJson] (1:value|2:key) of json (list|array) %string% in %json% [skJson] [value[s]] %objects% of json (list|array) [%string%] [skJson] (1:(1st|first)|2:(2nd|second)|3:(3rd|third)|4:last|5:%integer%) element of json (list|array) [%string%]
set value of json list "1::list[1]::data" in {_json} to "[]"
remove values 1 and "Hello true" of json list from {_json}
remove 2nd element of json list from {_json}
add diamond sword to json list "0::list" in {_json}
remove all "new test key" of json list "array[0]" from {_json}
2.9
The new documentation you will find here: click here
A very general effect that can change many json object. The json object can be only set/remove/removeAll
[skJson] (:key|:value)[2:s] of json object %string% in %json% [skJson] [by] (:key|:value)[s] %objects% of json object [%string%] [skJson] %objects% of json (object|array|list) [%string%]
set value of json object "data::key" in {_json} to "new test key"
set key of json object "data::key" in {_json} to "test key"
set key of json object "list" in {_json} to "array"
set value of json object "this-a test-what i need to <>-_::data" in {_json} to iron sword
remove value "test key" of json object "data" from {_json}
remove all "new test key" of json object "data" from {_json}
2.9
You can get the count values in the given json
[skJson] number of (0:key|1:value) %objects% in %json%
number of key "test" in %json%
2.9
You can get json from cache storage by key defined by you
[skJson] json %string% [skJson] all cached jsons
on script load:
set {_json} to json "your"
send {_json} with pretty print
2.8.0 - performance & clean
Returns the index of the key/value in the ListObject
What is ListObject? ListObject is shortcut for `[{}, {} ...]`
That means the object indexed by integer in the list
This expressions allows you found the key/value in the inner objects in the list.
[skJson] [get] index of (:key|:value) %object% in [object( |-)list] [%string%] of [json] %json%
2.9
Represent sort of literals for skJson
[skJson] (1:(1st|first)|2:(2nd|second)|3:(3rd|third)|4:last|5:%integer%) element of %jsons%
on script load:
set {_json} to json from location(10,1,1)
send first element of {_json}
send last element of {_json}
send 5 element of {_json}
send 3rd element of {_json}
2.9
loops of values/key for json
json-value, json-key
[skJson] [the] json-(:value|:key)[-<(\d+)>]
on script load:
set {_json} to json from location(10,1,1)
loop values of {_json}:
send json-value, json-key
2.9
latest:
- support now also multiple items as input
- support json content from webpage
- removed empty json array/object, cause it's not necessary while
skJson know parsing object
original docs: click here
skripthub docs:
It's allow create json from any source also from the file
[skJson] json from [1:(text|string)|2:([json]|:yaml) file|3:web[site] [file]] [object] %objects% [skJson] @<^(\{|\[).+(\}|\])$>
on script load:
set {_json} to json from json file "plugins/Skript/json-storage/database.json"
set {_json::*} to json from "{'test' :true}", "B"
set {_json} to json from diamond tools
set {_json} to json from player's location
set {_json} to json from player's inventory
set {_json} to json from yaml file <path>
set {_json} to json from website file "https://json.org/sample.json"
*Literal
set {_json} to @{"test": true, "var": {_test}}
2.9, 2.9.3 - Literal parsing
Allows you to better parse json
{
"test": "skJson"
"Object": {
"new": "data"
}
[skJson] %jsons% with [(:uncoloured|:uncolored)] pretty print
set {_json} to json from "{'test': 'skJson', 'Object' : {'new': 'data'}}"
send {_json} with pretty print
send {_json} with uncolored pretty print
2.9
[the] json size of %jsons% %jsons%'[s] json size
set {_json} to json from text "{'sample': {}, 'second': []}"
if json size of {_json} > 1:
send {_json} is bigger than 1.
2.9
Its allow convert Skript list variable to Json
[the] form[atted json] of %jsons% %jsons%'[s] form[atted json]
on script load:
set {_json::A::1} to false
set {_json::A::2} to true
set {_json::B::some} to "some great value"
send {_json::*}'s form
1.3.0
Values/Key of Json
[skJson] (0:(value %string% of %json%)|1:(values [%string%] of %json%))
on script load:
set {_json} to json from location(10,1,1)
send values of {_json}
send value "world" of {_json}
Checkout <b> Loops </b>
2.9
value-expression for getting file/link from current watcher event
[the] [event-](file|link)
2.9
value-expression for getting uuid from current watcher event
[the] [event-](uuid|id)
2.9
Its allow to change directly keys/values in the given json file
[skJson] edit (0:value|1:key) %string% of json file %string% to %object%
on script load:
new json file "plugins\SkJson\jsons\test.json"
command edit:
trigger:
edit value "command" of json file "plugins/SkJson/jsons/test.json" to player's tool
2.8.5
You can create virtual json in memory
[skJson] [create] new json storage [named] %string%
on script load:
create new json storage named "json-storage"
send json "json-storage"
2.9
Its allow convert Json to variable skript list
[skJson] [:async] (map|copy) %json/string% to %objects%
on script load:
set {_json} to json from file "plugins/skript/#.json"
map {_json} to {_json::*}
1.9, 2.9 - Support mapping json from functions
You can register listener for json file, and while the file is updated the cache for this file will be also so.
(:make|:stop) [json] watcher listen to %string%
on script load
make json watcher listen to "mine.id"
stop json watcher listen to "mine.id"
2.8.0 - performance & clean
You can works with the cache instead of reopening the file again & again.
[skJson] link [json] file %string% as %string% [(:and make) [[json] watcher] listen]
on load:
link json file "<path to file>" as "mine.id"
link json file "<path to file>" as "mine.id" and make json watcher listen
2.8.0 - performance & clean
[skJson] new json file %string% [(:with) content %object%]
on script load:
new json file "plugins\SkJson\test.json"
set {_json} to json from website "https://raw.githubusercontent.com/mozilla/node-convict/master/lerna.json"
new json file "plugins\SkJson\test.json" with content {_json}
2.6.2
It's allow save cached json back to the file
[skJson] save json %string% [skJson] save all jsons
on unload:
save json "test"
save all jsons
2.8.0 - performance & clean
[skJson] SkJson stop server with code [%integer%]
You can unload the json file.
[skJson] unlink json %string%
on load:
unlink json "mine.id"
2.8.0 - performance & clean
Write new data directly to json file (File will be rewritten!
[skJson] write %object% to json file %string%
on script load:
new json file "plugins\SkJson\jsons\test.json"
command write:
trigger:
write json from website "api-website" to json file "plugins/SkJson/jsons/test.json"
2.8.5
Handle all files from folder
[skJson] [:async] load json files from %string% and save it in %string% [skJson] [:async] load json files from %string% and let json watcher listen to all with save it in %string%
load json files from "plugins/raw/" and save it in "raw"
loop values of json "raw":
send json-value
*Since 2.9 [30.8.2023]*
load json files from "plugins/SkJson/jsons" and let json watcher listen to all with save in "raw"
loop values of json "raw":
send json-value
2.9 [30.8.2023] - add support for json watcher to all files
will only run when the json watcher notices a change in the file
[on] [json-] watcher save [with priority (lowest|low|normal|high|highest|monitor)]
on json watcher save
2.9
You can handle the discord webhooks via this section.
Can handle also embeds, Request method is PATCH/POST/PUT as always.
You can define the content, headers of each request..
Aso the request shall be sent asynchronous
You can use Json/String, also variables and functions in this section.
! Recommended read that Discord webhooks api documentation
! Recommended read that Embed generate webpage "
! Recommended default json payload Json Payload (Lorem)
[skJson] [:async] send (:web|:discord) request %string%
command web:
trigger:
async send web request "https://webhook.site/4e2e350b-4a8f-4863-85c5-e833e4ec110b":
attachments:
1: "C:\Users\nexti\Documents\Lekce\index.html"
content: "{fromSkJson: '?', ?: true}"
command without-embed:
trigger:
async send discord request "https://discord.com/api/webhooks/1128075537919770798/y78NK-odks6Lod5kimmhcd9YWQfhFzPU1YA-VyD5bqWMGxaeYXxp5jTxpnNI9Yhw1Rgt":
header: "Content-Type: application/json"
data:
tts: true
content: "{'payload:' true}" # this can be any json encoded string or json
command embed:
trigger:
async send discord request "https://discord.com/api/webhooks/1128075537919770798/y78NK-odks6Lod5kimmhcd9YWQfhFzPU1YA-VyD5bqWMGxaeYXxp5jTxpnNI9Yhw1Rgt":
header: "Content-Type: application/json"
data:
username: "AAAA"
avatar-url: "https://google.com"
tts: true
content: "" # content never can be empty, so when you want to send only embed, you need to put here empty string
embed:
id: 102018 # when you put here null, or auto, the value will be generated automatically.
fields: "{}"
author: "{name: 'CoffeeRequired'}"
title: "Hello there"
thumbnail: "{url: 'https://cravatar.eu/helmhead/_F0cus__/600.png'}"
color: "##21a7c2" # that support all hex colors.. not minecraft
command embedAtt:
trigger:
async send discord request "https://discord.com/api/webhooks/1128075537919770798/y78NK-odks6Lod5kimmhcd9YWQfhFzPU1YA-VyD5bqWMGxaeYXxp5jTxpnNI9Yhw1Rgt":
attachments:
1: "*/generate_doc.sk" # star means the parser will search for the file recursively from the root directory
data:
tts: false
content: "hello from attachments"
2.9
Create & handle requests via json
Checkout this link click here for json examples of dummyJson api
Allowed all basic types of requests [GET, POST, PUT, DELETE, PATCH, HEAD, MOCK, MODIFY, ENTRY, NOTE]
[skJson] [:async] make [new] %requestmethod% request to %string% [skJson] (create|make) [new] %requestmethod% request to %string% [with header[s] %json/strings% [and with body %json/strings%]] and (stored|store it) in %objects%
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}
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, quantity: 2}]}"
save incorrect response: true
lenient: true
save:
content: {-content}
headers: {-header}
status code: {-code}
url: {-url}
command response:
trigger:
send {-content} with pretty print
2.9.4
Return base64 encoded string
b64(object: object)
serial: b64("This is a test"
2.9
Return a your defined delimiter in the config.yml
skjson_getdelim(bool: boolean)
send "my delimiter is: %skjson_getdelim()%"
2.9
JSON representation in skript
json
2.9
webhooks
json-webhook
2.9
This site uses cookies to provide services, personalize ads, and analyze traffic.