skJson by CoffeeRequired

Working with json in skript

Events

1

Expressions

24

Effects

24

Conditions

12

Types

5

Sections

2

Structures

0

Total

68

SkJson 2.9 7 days, 10 hours and 44 minutes ago

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[s][/s][s]
* Json is empty
* Type of json

Expressions
* Count value/key[s] in the Json.[/s][s]
* 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[s] of JSON[/s][s]

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
* [url=https://skjson.xyz/documentation/beta#event-jsonwatchersave]Json watcher save[/url]

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

Functions
* b64 (Decoding from String to B64)
* [url=https://skjson.xyz/documentation/beta#function-function[/i]skjson_getdelim]skjsongtdelim (Get your defined delimiter)[/url]

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
[/s][/s][/s]

View Update

SkJson legacy 7 days, 10 hours and 46 minutes ago

SkJson 2.8 (latest 2.8.6) Legacy
This is legacy version fro Skript 2.6.3 +

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 exists
* Json file is cached
* Json file is empty
* Json file is listening
* Json has value/key
* Json is empty
* Type of json

Expressions

* All cached jsons
* Array or List formatted to JSON.
* Count of objects/phrases
* Elements/Values of the json
* Get cached json
* Get last response
* Json size of given Json
* New json
* Pretty json

Effects
* Execute a http request
* JsonWatcher - Start listening to file
* JsonWatcher - Stop listening to file
* Link json file with defined cache.
* Map json to skript list
* New json file
* Save cached json to file
* UnLink or Unload json file
* Write json file with contents
* change json file
* link and load all json files from given folder

Functions
* jsonfile

Types
* json element
* json file

Changers
* Default changer of skJson (SET/REMOVE/ADD)


Resolved Issues.
* #71
* #64
* #63
* #42
* #41
* #39
* #38
* #37
* #24
* #22
* #21
* #20
* #19
* So one...

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)

@!Legacy

View Update

SkJson 2.9 9 days, 8 hours and 9 minutes ago

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[s][/s][s]
* Json is empty
* Type of json

Expressions
* Count value/key[s] in the Json.[/s][s]
* 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[s] of JSON[/s][s]

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
* [url=https://skjson.xyz/documentation/beta#event-jsonwatchersave]Json watcher save[/url]

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

Functions
* b64 (Decoding from String to B64)
* [url=https://skjson.xyz/documentation/beta#function-function[/i]skjson_getdelim]skjsongtdelim (Get your defined delimiter)[/url]

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
[/s][/s][/s]

View Update

SkJson 2.0 9 days, 8 hours and 24 minutes ago

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 Snippets, we also have documentation for both versions with examples. The documentation is automatically updated! Let's get started on the changes!

More here!
https://github.com/SkJsonTeam/skJson/releases/tag/2.9

View Update

SkJson 2.8.6 89 days, 15 hours and 3 minutes ago

SkJson 2.8.6
Fixed several issue with Paper/Purpur and skript 2.7.0 beta.
Fixed nulls elements by (SET/ADD) new element to JsonArray/JsonObject
Add loading json files from folder to the cache
https://github.com/SkJsonTeam/skJson/releases/tag/2.8.6

View Update

SkJson 2.8.5 - Fixed java issues and file writing 130 days, 15 hours and 51 minutes ago

https://github.com/SkJsonTeam/skJson/pull/50


Full Changelog: https://github.com/SkJsonTeam/skJson/compare/2.8.4...2.8.5


Thank everyone for their support for ideas
Sincerely coffeeRequred.
❤>"

View Update

Small fixes 150 days, 10 hours and 25 minutes ago

SkJson 2.8.3

Doc's updated (SkUnity, SkriptHub)
Skript version:

  • 2.7.0 - Beta 1,
  • 2.7.0 - Beta 2,
  • 2.6.4

Changed
  • small changes was also in the Execute web request




(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%]
[/code]


Fixed

  • size of %json% -> json size of %json%, cause old syntax has conflict with vanilla skript
  • fixed block thread in the async method for sending request's and wriiting to file

Added
  • Added convertation from .yml files to .json


set {_yaml json} to json from yaml file "..../test.yaml"

[/code]

  • more properties of request's responses


[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
[/code]







What's Changed


Full Changelog: https://github.com/SkJsonTeam/skJson/compare/2.8.2...2.8.3

Thank everyone for their support for ideas
Sincerely coffeeRequred.


View Update

Small fixes 165 days, 16 hours and 41 minutes ago


View Update

Big Changes! [Potencialy break Skripts] 181 days, 22 hours and 7 minutes ago

A lot of changes have been made, practically the whole addon is redesigned for performance reasons, some features are added but please read more on Github



Thanks CoffeeRequired!

View Update

Bug fixing ItemStack, CustomModelData, Encoding, Performance, CleanUP 213 days, 14 hours and 42 minutes ago

skJson 2.7.0⚠️
Introduce


Hello everyone.

- Fix small bugs
- Fixed bundles
- Cleanup code
- fix Typos


[h3]Example[/h3]

{
"items": [
{"==":"org.bukkit.inventory.ItemStack","v":3218,"type":"APPLE","meta":{"==":"ItemMeta","meta-type":"UNSPECIFIC","display-name":"{\"extra\":[{\"bold\":false,\"italic\":false,\"underlined\":false,\"strikethrough\":false,\"obfuscated\":false,\"color\":\"white\",\"text\":\"Tomate\"}],\"text\":\"\"}","custom-model-data":1}},
{"==":"org.bukkit.inventory.ItemStack","v":3218,"type":"APPLE","meta":{"==":"ItemMeta","meta-type":"UNSPECIFIC","display-name":"{\"extra\":[{\"bold\":false,\"italic\":false,\"underlined\":false,\"strikethrough\":false,\"obfuscated\":false,\"color\":\"white\",\"text\":\"Tomate2\"}],\"text\":\"\"}","custom-model-data":1}},
{"==":"org.bukkit.inventory.ItemStack","v":3218,"type":"APPLE","meta":{"==":"ItemMeta","meta-type":"UNSPECIFIC","display-name":"{\"extra\":[{\"bold\":false,\"italic\":false,\"underlined\":false,\"strikethrough\":false,\"obfuscated\":false,\"color\":\"white\",\"text\":\"Tomate3\"}],\"text\":\"\"}","custom-model-data":1}}

],
"nums": [
1,
2,
3,
0
]
}

command try:
trigger:
set {_} to json from file "items/test.json"
send {_}
remove json object player's tool from nested object "items" of {_}
remove json index 1 from nested object "nums" of {_}
send {_} with pretty print
````
* Fixed olders issue contains invalid mapping or invalid converting to the json.
* Also fixed issue what should remove the meta from the ItemStack, which should not be removed.
* Also fixed issue with CustomModelData contains id of model was lost from converting to json.
* Path-Hotlinking will not added because it's necessary use that hotlink instead link file instead.
* #13 null as new Data (Bug) was fully fixed -> Will apear error when you tried converting null json to the object.
* #15 fully supported new syntax for remove json from nested object.
* #18 - Item Conversion. When you put item to the Skript list and then you want retrieve it as json form, you got broken json from BukkitSerilization instead of our json normal representation
* #19 UTF-8 encoding error, Fixed
* #20 Item-Data encoding error, Fixed
* #24 Bundle(Custom model Data) lost, Fixed (Minecraft 1.19+)


PLEASE READ THE NEW SYNTAXE'S! on the Skript hub



Please check SkriptHub or Wikipedia for syntax changes.
## ❌ If you found any bugs, feel free to post it.

Sincerely, Coffee.

Full Changelog: https://github.com/cooffeeRequired/skJson/compare/2.6.0...2.7.0

View Update

pre-release skJson 2.7.0 217 days, 21 hours and 34 minutes ago

{
"items": [
{"==":"org.bukkit.inventory.ItemStack","v":3218,"type":"APPLE","meta":{"==":"ItemMeta","meta-type":"UNSPECIFIC","display-name":"{\"extra\":[{\"bold\":false,\"italic\":false,\"underlined\":false,\"strikethrough\":false,\"obfuscated\":false,\"color\":\"white\",\"text\":\"Tomate\"}],\"text\":\"\"}","custom-model-data":1}},
{"==":"org.bukkit.inventory.ItemStack","v":3218,"type":"APPLE","meta":{"==":"ItemMeta","meta-type":"UNSPECIFIC","display-name":"{\"extra\":[{\"bold\":false,\"italic\":false,\"underlined\":false,\"strikethrough\":false,\"obfuscated\":false,\"color\":\"white\",\"text\":\"Tomate2\"}],\"text\":\"\"}","custom-model-data":1}},
{"==":"org.bukkit.inventory.ItemStack","v":3218,"type":"APPLE","meta":{"==":"ItemMeta","meta-type":"UNSPECIFIC","display-name":"{\"extra\":[{\"bold\":false,\"italic\":false,\"underlined\":false,\"strikethrough\":false,\"obfuscated\":false,\"color\":\"white\",\"text\":\"Tomate3\"}],\"text\":\"\"}","custom-model-data":1}}

],
"nums": [
1,
2,
3,
0
]
}


```vb
command try:
trigger:
set {_} to json from file "items/test.json"
send {_}
remove json object player's tool from nested object "items" of {_}
remove json index 1 from nested object "nums" of {_}
send {_} with pretty print
````
Please check SkriptHub or Wikipedia for syntax changes.
❌ If you found any bugs, feel free to post it.

Sincerely, Coffee.

Full Changelog: https://github.com/cooffeeRequired/skJson/compare/2.6.21...pre-release-2.7.0>"

View Update

Item Conversion in JSON (Form of Skript list) Supported! 234 days, 21 hours and 9 minutes ago

skJson 2.6.21⚠️
Introduce
Hello everyone.

New conventors for json.

  • Fix small bugs, #18
  • Cleanup code
  • fix Typos

Fixed.

command try:
trigger:
set {_test::*} to diamond sword named "&aA", apple, stone pickaxe
broadcast {_test::*}'s form with pretty print

set {_test::item1} to diamond sword named "&aA"
set {_test::item2} to stone pickaxe
set {_test::item3} to apple

broadcast {_test::*}'s form with pretty print
on load:
execute console command "try"


Please check SkriptHub or Wikipedia for syntax changes.

❌ If you found any bugs, feel free to post it.
Sincerely, Coffee.

Full Changelog: 2.6.2...2.6.21

View Update

Updated 2.6.2 237 days, 15 hours and 9 minutes ago

->

View Update

skJson 2.6.2 Support java 11, Automatic parsing 241 days, 16 hours and 46 minutes ago

skJson 2.6.2⚠️
Introduce


Hello everyone.

- New conventors for json.
- Adding automatic parsing.
- Cleanup code
- fix Typos


From

command test:
trigger:
set {_loc-json} to json from player's location
set {_loc} to {_loc-json} parsed as a location
teleport player to {_loc}

To
command test:
trigger:
set {_loc-json} to json from player's location
teleport player to {_loc-json}


Please check SkriptHub or Wikipedia for syntax changes.
❌ If you found any bugs, feel free to post it.


Sincerely, Coffee.

What's Changed
* New Conventors by @cooffeeRequired in https://github.com/cooffeeRequired/skJson/pull/14

Full Changelog https://github.com/cooffeeRequired/skJson/compare/2.6.1...2.6.2

View Update

skJson (Mapping/Appending) 2.6.1 244 days, 6 hours and 40 minutes ago

skJson 2.6.1⚠️
Introduce

Hello everyone.
Hotfixed issue #11 , also the #13
Also was fixed all mapping / append / write issues.


Please check SkriptHub or Wikipedia for syntax changes.
## ❌ If you found any bugs, feel free to post it.

Sincerely, Coffee.

Full Changelog: https://github.com/cooffeeRequired/skJson/compare/2.5.9...2.6.1

View Update

skJson 2.5.9 245 days, 19 hours and 2 minutes ago

skJson 2.5.9 ⚠️

Introduce

Hello everyone.
Fixed changers, for json you are now able to remove/add or set objects even with cached json.
Added removing/setting for nested objects

This error was related to this thread #8


Version 2.5.9
Example


on load:
set {_json} to json from string "{'A': [1,2,3,4,{'B':false}]}"
set json value "A[1]" of {_json} to true

# Before {"A":[1,2,3,4,{"B":false}]}

remove json value "A[4]:B" from {_json}
add values 1,2,3,4 to {_json}
send {_json}

# After {"A":[1,2,3,4,{}]}

load json file "try3.json" as "try"
send cached json "try"
set json value "A[0]" of cached json "try" to true
send cached json "try"


Please check SkriptHub or Wikipedia for syntax changes.
❌ If you found any bugs, feel free to post it.

Sincerely, Coffee.

Full Changelog: https://github.com/cooffeeRequired/skJson/compare/2.5...2.5.9

View Update

skJson 2.5 246 days, 17 hours and 55 minutes ago

skJson 2.5 ⚠️
Introduce


Hello everyone.
This is a big milestone for skJson addon (*skript-gson*)
One of the first pieces of information is that it has been renamed from the current skript-gson to skJson. I renamed this addon because the gson in the name said little to anyone and was not as representative. thus skJson contains both json in the word and Skript (sk)

I should also mention that support for older versions of minecraft server has been added. Since version 1.8.8 this addon is able to work.

I must also mention that the kernels for file handling and json serialization have been redesigned. For example, you can now serialize nbt and or entities.

A lot of syntax has been modified and simplified. one of my favorites is the Append effect, here is an example

append player's tool with key uuid of player as nested object "data:players tools[1]" to json file "..."

Don't worry I'll show you everything here, the new syntax is more intiative and I hope you'll find it easier to work with this addon, at the moment the addon supports around 24/25 data-types, if you want to add some that isn't just create a github thread as suggestion and I'll be happy to take a look.

I would also like to thank the total number of support and downloads for this addon and that is 4129x to date.

Alright let's get on with the news.

News
[h3]Adapters ⏺️[/h3]
NBT, Entity, Chunk, ItemStack, World, Inventory, bukkit-types, and some Skript-types.

Please check SkriptHub or Wikipedia for syntax changes.

Sincerely, Coffee.

Full Changelog: https://github.com/cooffeeRequired/skJson/compare/2.1.1...2.5

View Update

Updated AutoUpdaters. Skript-gson 2.1.0 263 days, 16 hours and 54 minutes ago

https://github.com/cooffeeRequired/skript-gson/compare/2.0.4...2.1.0[/URL]>"

View Update

skript-gson 2.0.4 - Changed internal object mapping 264 days, 16 hours and 55 minutes ago

>"
command saveinv:
trigger:
set {inv} to json from player's inventory

command listinv:
trigger:
map {inv} to {_inv::*}
loop (indices of {_inv::contents::*}):
if {_inv::contents::%loop-value%::*} is set:
set {_item} to {_inv::contents::%loop-value%::*}'s form parsed as skript-type
give {_item} to "player's name" parsed as player

[/code]

View Update

skript-gson 2.0.3 274 days, 20 hours and 50 minutes ago

View Update

skript-gson 2.0.2 279 days, 19 hours and 20 minutes ago

added - all json elements from %jsonelement%

View Update

skript-gson 2.0.2 280 days, 5 hours and 40 minutes ago









set {_json} to new json from string "{'A': {}, 'B': [], 'C': {'G': {}}}"
add false to {_json} # example 1
add "A:test;false" to {_json} # example 2
add "C:G:test;A" to {_json} # example 3

# Show case 1
{"A": {}, "B": [], "C": {"G": {}}, "3": false}
# Show case 2
{"A": {"test": false}, "B": [], "C": {"G": {}}}
# Show case 3
{"A": {}, "B": [], "C": {"G": {"test": "A"}}}





View Update

skript-gson 2.0.0 284 days, 8 hours and 34 minutes ago

New release of skript-gson it's out. 2.0.0 Fixed all known mapping bugs, also added SkriptTypes and Bukkit type conversion, also Inventory. Changed functionality and loaded Json as a custom ID, etc. https://skripthub.net/docs/?addon=skript-gson https://github.com/cooffeeRequired/skript-gson/releases/tag/2.0.0

View Update

skript-gson 1.4.0 (Loading file as given ID) 293 days, 12 hours and 25 minutes ago





View Update

skript-gson 1.3.3 - small fix 295 days and 55 minutes ago

  • Fixed writing to file.

View Update

Fixed version skript-gson 297 days and 12 hours ago

[quote][/quote]

View Update

Skript-Gson 1.3.1 303 days, 20 hours and 31 minutes ago

View Update

Skript-gson 1.3.0 updated 306 days, 19 hours and 37 minutes ago

[quote][/quote] [quote][/quote]

View Update

Skript-Gson 1.2.0 317 days and 16 hours ago

https://github.com/cooffeeRequired/skript-gson/releases

Skript-Gson 1.2.0

Hello everyone
This patch won't please some of you, mainly because after reaching the 50th download milestone we noticed that few people know how Non-Literal Json means

json ...
works.

So we decided to remove this feature and work on improvements in putting and adding to the Json file/variable.
The last version is rather a mess and so this version will be cleaned of all necessities plus the examples will be corrected so that the layman can understand them

Format
Finished:
ExprNewJson.class

[a] [new] json from [(text|string|request)] %object%

Removed:
Non-Literal from ExprNewJson.class

Added: serialization\deserialization for
ItemTypes,BlockData
etc.. More here

Expressions
Finished:
ExprJsonListToJsonElement.class
-> Fixed working with objects, now you can change the whole variable.
Added:
ExprCountOfJson.class

[a] count of [key] %string% in %jsonelement%

Added:
ExprJsonRegexMatch.class

[json] %jsonelement% [regex] match[es] %string%

♾️ Change/Fix:
ExprLoadJsonFile.class
-> At this moment i cannot guarantee the syntax

Effects
♾️ Planed:
EffHandleJsonFile.class

load json file %string% as id %string%
unload json file [id] %string%
save json file [id] %string%

♾️ Planed-Rework:
EffMapJsonToList.class
-> will contains new feature.
♾️ Planed-Rework:
EffWriteToFile.class
-> will contains new feature.

Conditions
Added:
CondJsonHas.class

%jsonelement% has (:key|:value) %objects%
%jsonelement% has list (:keys|:values) %objects%

♾️ Planed-Rework:
CondJsonValueObject.class

[a] value %string% in %jsonelement% is (:true|:false)
[a] value %string% in %jsonelement% is string
[a] value %string% in %jsonelement% is integer
[a] value %string% in %jsonelement% is boolean
[a] value %string% in %jsonelement% can be parsed

Thank you all for your attention. \
Sincerely Coffee.

FTW *Skript-Gson*
*>"

View Update

Skript-Gson 1.1.3 - Sanitize Patch. 321 days, 9 hours and 54 minutes ago



Hello everyone

This patch fixes bugs #1, #2
and also fixes a syntax error where you couldn't use variables for example in

'append.. '


Change from
...

"[a] [new] json from (string|text) %string%",
"[a] [new] json from file [path] %string%",
"json (([<.+>])|({<.+>}))",
"(<'.+'>)"

...

On \

...

"[a] [new] json from (string|text) %string%",
"[a] [new] json from file [path] %string%",
"(json ((<\\[.*\\]>)|(<\\{.*\\}>)|((\\\"|')<.+>(\\\"|'))|(<(true|false)>)))"

...

[h3]Also added a new substring \[/h3]
[a] json file %object% is exist

View Update

Fix map conversion 321 days, 12 hours and 55 minutes ago

https://github.com/cooffeeRequired/skript-gson/releases/tag/1.1.1

View Update

Updated Skript-Gson 321 days, 17 hours and 18 minutes ago

https://github.com/cooffeeRequired/skript-gson/releases/tag/1.1.0

View Update

Skript-Gson 321 days, 21 hours and 35 minutes ago



  • (load|open)[ed] json file %string%



  • write [new] data %jsonelement% to [json] file %object%


  • append(ing|) [new] data %jsonelement% to [json] file %object% [(:as) [nested] object %-jsonelement% [(:with) [property] key %-string/integer%]]

https://github.com/cooffeeRequired/skript-gson/compare/1.0.2-Beta...1.1.0>"

View Update

Added new syntax for Add 326 days, 21 hours and 15 minutes ago

Check out : https://skripthub.net/docs/?id=8183

View Update

skJson 327 days, 8 hours and 10 minutes ago



















on script load:
# From String
# We can use escape sequences so two double quotes, or we can use single quote
# Or we can define only KEYS without any quotes
set {_json} to json from text "{""A"": false}"
set {_json} to json from text "{'A': false}"
set {_json} to json from text "{A: false}"

# From file (json/yaml)
# YAML: you can your old yaml file and SkJson will convert that to JSON file
set {_json} to json from json file "plugins/SkJson/Files/test.json"
set {_json} to json from yaml file "plugins/SkJson/Files/test.yaml"

# From website
# That will work only for GET! If you want to use other methods you should use requests
set {_json} to json from website "https://dummyjson.com/products/1"

# From any Skript/Bukkit object
set {_json} to json from location(10, 20, 30, world("world"))



on script load:
async make POST request to "https://dummyjson.com/carts/add":
header: "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



# here we will create a new file
options:
file_path: "plugins/SkJson/jsons/test.json"

on script load:
new json file {@file_path} if json file {@file_path} does not exist

# here we will work with the json file

set {_json} to json from file {@file_path}

# writing to file
set {_data} to json from location(10, 20, 30, world("world"))
write {_data} to json file {@file_path}

# editing directly file
edit value "world" of json file {@file_path} to "New World"

# editing file with step over

# getting the json file as Json object
set {_json} to json from file {@file_path}
set value of json object "world" in {_json} to "New World(By rewrote)"

# write file back to JSON
write {_json} to json file {@file_path}



options:
file_path: "plugins/SkJson/jsons/test.json"

on script load:
# here we will create a new file
new json file {@file_path} if json file {@file_path} does not exist
# here we will linked our file to our memory.
link json file {@file_path} as "your_specified_value" if json file {@file_path} exists

# here we will set value to memory reference of your file.
set value of json objct "location" in (json "your_specified_value") to location(10, 20, 30, world("world"))

# here we will get location of memory
set {_location} to value "location" of (json "your_specified_value")
# that will return {"==":"org.bukkit.Location","yaw":0.0,"world":"world","x":10.0,"y":20.0,"z":30.0,"pitch":0.0}

# here we will save memory reference back to file
save json "your_specified_value"



# let's say we have a command test and we work with Player Location.
command test:
trigger:
set {_json_location} to json from location of player
teleport player to {_json_location}
# that will teleport player to location converted from JSON object to location

set {_item} to diamond sword named "Test"
set lore of {_item} to "&6Gold" and "&7Silver"
enchant {_item} with Sharpness 5
set {_json_item} to json from {_item}

give {_json_item} to player

View Update