Skip to content

Skript-Gson 1.1.0

Compare
Choose a tag to compare
@cooffeeRequired cooffeeRequired released this 06 Nov 10:32
· 608 commits to main since this release

Skript-Gson 1.1.0

This this realese brings new features such as. \

Expressions

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

Effects

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%]]

Examples


Before the change json

{
  "players": {
    "coffeeRequired": {
      "name": "coffee",
      "surname": "coffeeRequired",
      "isAdmin": false
    }
  }
}
on load:
    set {_file} to load json file "YouAreAwesome\test.json"
    set {_data} to json {"another":"Element"}
    write new data {_data} to json file {_file}

    '# Example 1. of append (without a nested and key)
    append new data {_data} to json file

    '# Example 2. of append (with nested, but without key)
    append new data {_data} to json file as nested object 'players;coffeeRequired'

    '# Example 3. of append (with nested, but without key)
    append new data {_data} to json file as nested object 'players;coffeeRequired' with key "newElement"

After a Write

{
  "another": "Element"
}

After a Append

# Example 1
{
  "players": {
    "coffeeRequired": {
      "name": "coffee",
      "surname": "coffeeRequired",
      "isAdmin": false
    }
  },
  "1": {
    "another":"Element"
  }
}

# Example 2
{
  "players": {
    "coffeeRequired": {
      "name": "coffee",
      "surname": "coffeeRequired",
      "isAdmin": false,
      "2": {"another":"Element"}
    }
  }
}

# Example 3
{
  "players": {
    "coffeeRequired": {
      "name": "coffee",
      "surname": "coffeeRequired",
      "isAdmin": false,
      "newElement": {"another":"Element"}
    }
  }
}


Full Changelog: https://github.com/cooffeeRequired/skript-gson/compare/1.0.2-Beta...1.1.0