Skip to content

SkJson 6.0.0 — HTTP reliability and core JSON

Latest

Choose a tag to compare

@cooffeeRequired cooffeeRequired released this 04 Jul 08:38
· 1 commit to main since this release

SkJson 6.0.0 — HTTP reliability and core JSON

SkJson 6.0.0 builds on the 5.6 baseline and focuses on outgoing HTTP reliability and core JSON path APIs.

Important

SkJson 6.0.0 requires Skript 2.15.0 or newer. It will not load on Skript 2.14 or older.

Note

SkJson handles outgoing HTTP requests (execute {_request} / on received http response). It does not provide an embedded web server or incoming request syntax such as reply … with ….


Requirements

Java 21+ (CI: 25)
Minecraft 1.16.5+ (CI: Paper 26.2)
Skript 2.15.0+ (tested with 2.15.4)
Optional NBT-API (shaded in jar)

Recommended stack: Paper 1.21.x+, Java 21+, Skript 2.15.4+.


What's new in 6.0.0

HTTP module

  • Query parameters — key:value pairs support values that contain colons; multiple add "key:value" to query params of {_req} calls compose correctly
  • MOCK method — prepare MOCK request on … returns a local synthetic 200 response ({"mock":true}) without a network call (blocking and non-blocking)
  • Full method coverage — GET, POST, PUT, PATCH, DELETE, HEAD, MOCK, plus json from website
  • Non-blocking requests — execute {_req} as non blocking with on received http response
  • Configurable client — shared HTTP client with connect/response timeouts and thread pool in config.yml

Recommended syntax for multiple query params:

reset query params of {_req}
add "skjson:demo" to query params of {_req}
add "probe:1" to query params of {_req}
set {_req}'s headers to json from "{'Accept':'application/json','X-Test':'ok'}"

Core JSON

  • set value at path … in … to … — dedicated path write effect
  • remove path … from … / delete path … in … — delete nested keys without rebuilding the document
  • .jsonc files — line/block comments and trailing commas stripped before parse
  • Performance — fast-path primitive parsing, bounded path token cache, NBT conversion LRU cache (configurable in config.yml)

Bug fixes (since 5.6.0)

HTTP

  • Query params — multiple key:value pairs no longer collapse into one broken URL key. Prefer adding parameters one at a time:

    reset query params of {_req}
    add "skjson:demo" to query params of {_req}
    add "probe:1" to query params of {_req}
  • MOCK requests — prepare MOCK request on … followed by execute {_req} returns local JSON without opening a socket:

    set {_req} to prepare MOCK request on "https://example.com/status"
    execute {_req}
    set {_res} to last response of {_req}
  • HEAD responses — prepare HEAD request on … / execute {_req} correctly yields an empty body; do not assume %body of {_res}% is JSON.

Syntax and behaviour

  • set value at path … in … to … — path writes use a dedicated effect instead of slower generic setters
  • remove path … from … / delete path … in … — nested keys can be removed without rebuilding the whole document
  • has path / contains path — probing a missing key does not spam warnings to the console
  • loop values of {_json}: — iterates object/array entries (%json-key-1%, %json-value-1%), not a single wrapped value
  • .jsonc files — json from file and bind/watch flows accept .jsonc like .json

Performance bottlenecks

  • JSON primitives — parse "…" as json and numeric/boolean literals skip unnecessary Gson round-trips on the hot path
  • Path reads — repeated value at path "…" in {_json} / path "…" of {_json} reuse a bounded path-token cache (size in config.yml) instead of re-tokenizing every access
  • Array index paths — value at path "items.0.name" in {_json} resolves array segments with integer parsing; read mode no longer mis-navigates array indices
  • Path writes — set value at path "…" in {_json} to … avoids extra allocation in high-frequency update loops
  • Object key pickers — last key of {_json} and indexed/random key access no longer copy entire entry sets on each call
  • File watcher — bind/watch reload compares compact snapshots (hash before full string equality) so unchanged saves do not trigger redundant cache refresh
  • File I/O — JSON serialization for disk writes reuses a shared serializer instance instead of creating one per write
  • NBT conversion — optional NBT → JSON uses an LRU cache (size in config.yml) to cut repeat conversion cost on items, chunks, and entities

Examples

# --- HTTP GET with query params ---
set {_req} to prepare GET request on "https://api.example.com/get"
reset query params of {_req}
add "skjson:demo" to query params of {_req}
add "probe:1" to query params of {_req}
set {_req}'s headers to json from "{'Accept':'application/json'}"
execute {_req}
set {_res} to last response of {_req}
set {_body} to parse "%body of {_res}%" as json
send "args: %value at path ""args"" in {_body}%" to player

# --- MOCK (no network) ---
set {_req} to prepare MOCK request on "https://example.com/get"
execute {_req}
set {_res} to last response of {_req}
assert status code of {_res} is 200

# --- Async ---
set {_req} to prepare GET request on "https://api.example.com/status"
execute {_req} as non blocking

on received http response:
    set {_res} to event-response
    broadcast "API status: %status of {_res}%"

# --- Path write / remove ---
set {_cfg} to json from "{user: {name: ""Alex""}}"
set value at path "user.name" in {_cfg} to "Bob"
remove path "user.role" from {_cfg}

Upgrade guide (from 5.6.0)

  1. Replace skjson.jar in plugins/ (keep a single copy — duplicate jars cause load warnings).
  2. Restart the server (recommended after any SkJson update).
  3. If you use HTTP query params, prefer add "key:value" to query params of {_req} instead of comma/and lists on set query params of {_req}.
  4. Enable HTTP in plugins/SkJson/config.yml if needed: enabled-http: true.

Install

  1. Download skjson.jar from the release assets below.
  2. Place it in plugins/ (Skript 2.15+ must already be installed).
  3. Restart the server.
  4. Review plugins/SkJson/config.yml (HTTP, NBT, watcher, cache sizes).

Project links

Resource Link
Wiki github.com/cooffeeRequired/skJson/wiki
Issues github.com/cooffeeRequired/skJson/issues
Performance notes performance.md

Full Changelog: 5.6.0...6.0.0