Resource icon

Addon skript-json 1.1.0

  • 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!

btk5h

Addon Developer
Jan 25, 2017
154
159
0
Pyongyang, North Korea
btk5h submitted a new resource:

skript-json - Seamless JSON integration for Skript

Idiomatic JSON integration for Skript. Convert JSON into list variables and vice versa.

Handle JSON objects using list variables. This addon was originally designed to work with Web APIs that use JSON for input and output, but it will also work well in any situation that requires parsing and serializing JSON.

Documentation/Source - Releases

Quickstart...

Read more about this resource...
 
I think you should methods for formatting chat with json. The addon is called skript-json so you should go all in with this :emoji_slight_smile:
 
I think you should methods for formatting chat with json. The addon is called skript-json so you should go all in with this :emoji_slight_smile:
I think you didn't understand the point of this addon.This addon isn't for minecraft's json chat. Even if the name says json, its not for minecraft's json chat. This addon is for api that uses json. There's also no point in adding in this when there are plenty of other addons that has json already. If you want minecraft json, then use json.sk (dev25 and below) or Bensku's built in json messages (dev26 and above).
u8dazJ4.png
 
I think you didn't understand the point of this addon.This addon isn't for minecraft's json chat. Even if the name says json, its not for minecraft's json chat. This addon is for api that uses json. There's also no point in adding in this when there are plenty of other addons that has json already. If you want minecraft json, then use json.sk (dev25 and below) or Bensku's built in json messages (dev26 and above).
u8dazJ4.png
Never knew it was already built into Skript - thanks!
 
```
set {_json::mapdata::bluespawn1} to sharpsk worldguard point 1 of region "hut%loop-value-1%blue" in world "%{loc.%loop-value-1%.red}'s world%"
set {_jsonastext} to "%the serialized json form of {_json::*}%"
set file contents of "json/%loop-value%.json" to "%{_jsonastext}%"

```
How do i make this be stored as a string in a json file instead of a json object?

```
  • "mainspawn":"x: -39.67, y: 52, z: -0.17" is what i want

  • "bluenexuses:1":{
    • "world":"cherrylandmc",
    • "__javaclass__":"org.bukkit.Location",
    • "x":41.0,
    • "y":27.0,
    • "z":107.0,
    • "pitch":0.0,
    • "yaw":0.0
    },
  • is what i get
    ```
 
```
set {_json::mapdata::bluespawn1} to sharpsk worldguard point 1 of region "hut%loop-value-1%blue" in world "%{loc.%loop-value-1%.red}'s world%"
set {_jsonastext} to "%the serialized json form of {_json::*}%"
set file contents of "json/%loop-value%.json" to "%{_jsonastext}%"

```
How do i make this be stored as a string in a json file instead of a json object?

```
  • "mainspawn":"x: -39.67, y: 52, z: -0.17" is what i want

  • "bluenexuses:1":{
    • "world":"cherrylandmc",
    • "__javaclass__":"org.bukkit.Location",
    • "x":41.0,
    • "y":27.0,
    • "z":107.0,
    • "pitch":0.0,
    • "yaw":0.0
    },
  • is what i get
    ```
Locations (and some other classes) are serialized in a special way so that they can be restored later by skript-json. If you're using another plugin that needs locations in a different format, you will need to create the string yourself instead of storing a location.
 
Locations (and some other classes) are serialized in a special way so that they can be restored later by skript-json. If you're using another plugin that needs locations in a different format, you will need to create the string yourself instead of storing a location.
My idea was to have files that users are able to edit by hand but that can also be read from skript. Does skript have a way to turn that location into a string?
 
My idea was to have files that users are able to edit by hand but that can also be read from skript. Does skript have a way to turn that location into a string?
Just strigfy it.

Setting:
code_language.skript:
set {_my-json-var::location::coordinates} to "%event-location%"
set {my-json-var::location::world} to world of event-location
set {_json} to json form of {_my-json-var::*}
should do the job


For converting it again you'd do:
Code:
map json {_json} to {_locations::*}
set {_coordinates::*} to {_locations::location::coordinates} parsed as "x: %number%, y: %number%, z: %number%"
set {_world} to world({_locations::location::world})
set {_location} to location({_coordinates::*}, {_world})