☮️
Skript-gson
  • skript-gson
  • Welcome
  • Foundations
    • 📝Syntaxes
      • 🔴Conditions
      • 🔵Effects
      • 🟢Expressions
      • 🟠Types
    • Printing
    • Creating
    • Deserialization
    • Serialization
  • About
Powered by GitBook
On this page

Was this helpful?

  1. Foundations

Creating

Official docs of Skript-gson

Examples of json creating

Getting json from a file

options:
    storage: json from file "plugins/YourAwesome/storage.json"

on load:
    broadcast new @{storage}   

Output will be whatever you have in that file.

on load:
    set {_example} to new json {"Hello": 1}
    broadcast {_example}
    

Output will be plain JsonElement (Json) {"Hello": 1}

Here you can't use double quotes because they are defined for String and therefore you will use single quotes, json will then automatically modify them so that the result is parsable. However, if you still want to use double quotes you will have to double them

on load:
    set {_example} to new json from string "{'Hello': 1}"
    broadcast {_example}
    

Output will be plain JsonElement (Json) {"Hello": 1}

JsonPrimitive is a json type that is only 'Integer/Boolean/Double/String'

on load:
    set {_primitive::Integer} to '1'
    set {_primitive::Boolean} to 'false'
    set {_primitive::Double} to '2.2'
    set {_primitive::String} to 'anything'
PreviousPrintingNextDeserialization

Last updated 2 years ago

Was this helpful?

Here you can create json from a sheet variable to help insert key and value into the sheet. However, we'll talk more in the

A class representing a Json primitive value. A primitive value is either a String, a Java primitive, or a Java primitive wrapper type.

Serialize tutorial
Java Documents