> For the complete documentation index, see [llms.txt](https://cooffeerequireds.gitbook.io/skript-gson/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://cooffeerequireds.gitbook.io/skript-gson/foundations/syntaxes/conditions.md).

# Conditions

### JSON is empty

patterns

```vala
json[element] %jsonelement% is empty 
json[element] %jsonelement% is(n't| not) empty 
```

{% tabs %}
{% tab title="Example" %}

```vala
on script load:
    set {-e} to new json from string "{'Hello': 'There'"}
    json {-e} is empty: 
        broadcast "is empty"
```

{% endtab %}
{% endtabs %}

### JSON File exists

patterns

```vala
json file %object% does exist
json file %object% does( not|n't) exist
```

{% tabs %}
{% tab title="Example" %}

<pre class="language-vala"><code class="lang-vala">on load:
<strong>    json file "test\test.json" exist:
</strong>        broadcast true
</code></pre>

{% endtab %}
{% endtabs %}

### Type of JSON

patterns

```vala
(json|jsonelement) %jsonelement% is [a] (:array|:object|:primitive) 
(json|jsonelement) %jsonelement% is(n't| not) [a] (:array|:object|:primitive) 
```

{% tabs %}
{% tab title="Example" %}

```vala
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
```

{% endtab %}
{% endtabs %}

### JSON has/hasn't key

patterns

{% code overflow="wrap" %}

```vala
%jsonelement% has ((:key|:value) %string/integer/boolean%|(:keys|:values) %objects%) 
%jsonelement% has(n't| not) ((:key|:value)%string/integer/boolean%|(:keys|:values) %objects%) 
```

{% endcode %}

{% tabs %}
{% tab title="First Tab" %}

```vala
on script load:
    set {-data} to new json from string "{'Hello': {'Hi': 'There'}}"
    if {-data} has keys "Hello", "Hi":
        send true
```

{% endtab %}
{% endtabs %}
