☮️
Skript-gson
  • skript-gson
  • Welcome
  • Foundations
    • 📝Syntaxes
      • 🔴Conditions
      • 🔵Effects
      • 🟢Expressions
      • 🟠Types
    • Printing
    • Creating
    • Deserialization
    • Serialization
  • About
Powered by GitBook
On this page
  • JSON is empty
  • JSON File exists
  • Type of JSON
  • JSON has/hasn't key

Was this helpful?

  1. Foundations
  2. Syntaxes

Conditions

JSON is empty

patterns

json[element] %jsonelement% is empty 
json[element] %jsonelement% is(n't| not) empty 
on script load:
    set {-e} to new json from string "{'Hello': 'There'"}
    json {-e} is empty: 
        broadcast "is empty"

JSON File exists

patterns

json file %object% does exist
json file %object% does( not|n't) exist
on load:
    json file "test\test.json" exist:
        broadcast true

Type of JSON

patterns

(json|jsonelement) %jsonelement% is [a] (:array|:object|:primitive) 
(json|jsonelement) %jsonelement% is(n't| not) [a] (:array|:object|:primitive) 
on load:
    set {-e} to new json from string "[1, false, 'test', null"
    json {-e} is array: 
        broadcast true

    set {-e} to new json from string "{'Hi': 'There'}"
    json {-e} is object: 
        broadcast true

JSON has/hasn't key

patterns

%jsonelement% has ((:key|:value) %string/integer/boolean%|(:keys|:values) %objects%) 
%jsonelement% has(n't| not) ((:key|:value)%string/integer/boolean%|(:keys|:values) %objects%) 
on script load:
    set {-data} to new json from string "{'Hello': {'Hi': 'There'}}"
    if {-data} has keys "Hello", "Hi":
        send true
PreviousSyntaxesNextEffects

Last updated 2 years ago

Was this helpful?

📝
🔴