✔Zkopírováno
You can check if the json file already exists or not.
json [file] %string% [already] exists json [file] %string% [already] does(n't| not) exists
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
[cached] json %string% is (load|linked) [cached] json %string% is(n't| not) (load|linked)
on load:
if cached json "test" if linked:
send true
2.8.0 - performance & clean
You can check if the json file empty
json file %string% is empty json file %string% is(n't| not) empty
Command jsonFileIsEmpty:
trigger
send true if json file "plugins/raw/test.json" is empty:
2.8.0 - performance & clean
Check if the file for given id is listening via JsonWatcher
[cached] json [id] %string% is listen [cached] json [id] %string% is(n't| not) listen
on load:
if cached 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
%json% [:directly] has (:value|:key)[s] %objects% %json% [:directly] does(n't| not) have (:value|:key)[s] %objects%
on load:
set {_json} to json from string "{'test5': [1], 'test6': ['key', 'key2', 'key3']}"
if {_json} has keys "test5", "test6", "A":
send true
else:
send false
2.8.0 - performance & clean
You can check if the json empty
json %json% is empty json %json% is(n't| not) empty
Command jsonIsEmpty
trigger
set {_json} to json object
send true if {_json} is empty
2.8.0 - performance & clean
You check json type of Json
type of %json% (is|=) (1:primitive|2:[json]object|3:array) type of %json% (is(n't| not)|!=) (1:primitive|2:[json]object|3:array)
on load:
if type of {_json} is primitive:
send true
2.8.0 - performance & clean
That will return jsons from your cache.
all cached jsons
command AllCachedJsons:
trigger:
send all cached jsons
2.8.0 performance & clean
It allows you to convert the sheet back to Json!
Value changes don't work for nested objects, to change the values of a nested object use Change
[the] form[atted json] of %objects% %objects%'[s] form[atted json]
on script load:
set {-json} to json from string "{'test': [1,2,3,false,null,'some'], 'test2': {'something': false}}"
map {-json} to {_json::*}
send "&9%{_json::*}'s form with pretty print%"
2.8.3 - Fix mapping for Skript beta, 1.3.0
You can get the exact number of identical keys or values from the entire json because `count of` works recursively.
(count|number) of (:key|[value]) %object% in %json%
set {_json} to json from string "{'A': [{'B': {}}], 'X': {}, 'UN': 'A'}"
add diamond sword to {_json} for given path "A[1]:B"
send {_json}
send count of diamond sword in {_json}
send number of key "A" in {_json}
send count of "A" in {_json}
2.8.0 performance & clean
Default changer you can change your current's jsons by those expressions
More information you can found here.. : click here
json list [%string%] in %json% (:keys|:values) of json object [%string%] in %json% json (:value|:key) %string% in %json%
remove diamond sword from {_json}
remove 2nd element from json list "pathxys" in {_json}
remove player's location from json list "pathxys" in {_json}
remove "hello" from keys of json object "pathxys" in {_json}
remove diamond sword from values of json object "pathxys" in {_json}
set json value "test:A" in {_json} to diamond sword
add player's location to json list "pathxys" in {_json}
2.8 - b2
You can get the main json values, or you can also get the use values for a given object/array you can also get a single value
loop-value, loop-element, loop-key
Means : -> entries entries mean the entry for the looped element, for example we have element {"B": false}
its entry will be loop-key = B, loop-element = false, loop-value = {B=false}
!Warnings: loop-key or loop-element you can use only for entries!
LOOP-PATTERNS ->
loop-value, loop-element, loop-key
(value|element) %string% of %object% (values|elements) [%string%] of %object% entr(y|ies) [%string%] of %object%
command GetElements:
trigger:
set {_json} to json from string "{'A': [{'B': {}}, false, true, 10, 20, 22.22, 'A']}"
# Get single element of json
set {_single} to element "A::1" of {_json} # That will return true cause, the first element of the array "A" is true
# Get multiple elements of json
set {_array::*} to elements "A" of {_json} # That will return whole array so that mean ({"B": {}}, false, true, 10, 20, 22.22, A)
# Loop through elements
loop elements "A" of {_json}:
send loop-value
# loop through entries of json
execute GET request "https://api.json.com/producs"
loop entries of request's body:
if loop-key = "data":
set {_data} to element "data" of loop-element
2.8.0 performance & clean
You can get json from cached internal storage by with a key defined by you
[cached] json %string%
on script load:
set {_json} to cached json "your"
send {_json} with pretty print
2.8.0 - performance & clean
Get last response of executed request
[SkJson] [(:current|:previous)] request's (2:body|3:code|4:connection headers|[user] (5:headers)|6:url) [skJson] (2:body|3:code|4:connection headers|[user] (5:headers)|6:url) of [(:current|:previous)] request
execute HEAD request to "https://dummyjson.com/products/1"
send body of current request with pretty print
send code of current request
send connection headers of current request
send user headers of current requestL
send url of current request
2.8.3, 2.8.0 performance & clean
[the] json size of %json% %json%'[s] json size
set {_json} to json from text "{'A': 1, 'B': 2, 'C': {'A': 'B', 'X': 'Y'}}"
if json size of {_json} > 1:
send "JSON's size is bigger the 1"
2.8.3, 2.8.0 - performance & clean
It's allow create json from any source also from the file
json[s] from [text|string] %object% json from [(json|:yaml)] file %string% [empty] json(-| )(0:array|1:object)
set {_json} to json from file "plugins/Skript/json-storage/database.json"
set {_json} to json from "{""test"":true}"
set {_json} to json from diamond sword
set {_json} to json from player's location
set {_json} to json from player's inventory
set {_json} to json from yaml file "string"
2.8.0 - performance & clean
Allows you to better parse json
{
"test": "skJson"
"Object": {
"new": "data"
}
%json% with pretty print
set {_json} to json from "{'test': 'skJson', 'Object' : {'new': 'data'}}"
send {_json} with pretty print
2.8.0 - performance & clean
You can execute a web request to rest api. with json encoded body/headers
(execute|send|make) [new] (<.+>|%string%) request to %string% [(:with headers) %strings/json%] [and with (:body|:data) %strings/json%] (execute|send|make) [new] (<.+>|%string%) request to %string% [with (:body|:data) %strings/json%] [and (:with headers) %strings/json%]
set {_headers} to json from text "{'Content-type': 'application/json'}"
execute MOCK request to "https://dummyjson.com/http/200"
execute GET request to "https://dummyjson.com/products/ with headers "Content-type: application/json"
execute POST request to "https://dummyjson.com/products/add" with headers "Content-type: application/json" and with data "title: TEST"
send request's body with pretty print
execute GET request to "https://dummyjson.com/products/ with headers "Content-type: application/json"
if request's code is 200:
send current request's body with pretty print
2.8.3, 2.8.0 performance & clean
You can register listener for json file, and while the file is updated the cache for this file will be also so.
make [json]watcher listen to %string%
on script load
make jsonwatcher listen to "mine.id"
2.8.0 - performance & clean
That will be stop listen file for given id
stop [json]watcher listen to [id] %string%
on script load
stop jsonwatcher listen to id "mine.id"
2.8.0 - performance & clean
You can works with the cache instead of reopening the file again & again.
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 jsonwatcher listen
2.8.0 - performance & clean
Mapping json to the List and get those values
(map|copy) %json/string% to %objects%
on load:
set {_json} to json from string "{'test': 'test2': {}}"
set {_json} to "{""test"": ""test2"": {}}"
map {_json} to {_json::*}
send {_json::*}
2.8.3 - b8210 (Fix mapping), 2.8.0 - performance & clean
You can create a new json file.
[:async] new json file %string% [(:with) (object|content)[s] %object%]
2.8.0 - performance & clean
It's allow save cached json back to the file
save [cached] json %string% save all [cached] jsons
on unload:
save cached json "test"
2.8.0 - performance & clean
You can unload the json file.
unlink json %string%
on load:
unlink json "mine.id"
2.8.0 - performance & clean
You can write/re-write to jsons
[re[-]]write %object% to [json file] %string/jsonfile%
command sk-example:
trigger:
set {_json} to json from player's world
write {_json} to json file "*.json"
2.8.0 performance & clean
You can change json file.
[:async] change (:value|:key) %string% of (%jsonfile/string%|(:json file) %string%) to %objects%
command jsonFileValue:
trigger:
change key "A" of jsonfile("plugins/<>/test.json") to "B"
2.8.0 - performance & clean
Handle all files from folder
load json files from %string% and save it in %string%
load json files from "plugins/raw/" and save it in "raw"
loop entries of json "raw":
send loop-element
2.8.6
Get json file from string/object input
jsonfile(file: string)
jsonfile("plugins/test/test.json")
2.8.0 - performance & clean
Represent the json class
json
2.8.0 - performance & clean
Represent the json file class
jsonfile
2.8.0 - performance & clean
This site uses cookies to provide services, personalize ads, and analyze traffic.