Miyuu's Image Board

help:hash_syntax


URL search parameters after the "?" in a URL form the overall hash structure of the JSON object "[1]":[#dtext-external-links] sent to the server.


h4#key-value. Key/value


Keys and values form a pair as a way to reference data. Each key/value pair in the search parameters is separated by an "&". The key is the text value to the left of the "=", and the "value" is the text value to the right of the "=" and may be "%" URL encoded "[2]":[#dtext-external-links].


h6.URL parameters



limit=100&page=1


h6.JSON object



{
"limit": 100,
"page": 1
}


h4#sub-hash. Sub-hash


Sub-hashes are supported by using square brackets "[ ]". The text value inside the square brackets is the sub key that the value will be added to.


h5.Single-level example


h6.URL parameters



search[name]=test&search[order]=id&limit=20


h6.JSON object



{
"search": {
"name": "test",
"order": "id",
},
"limit": 20
}


h5.Multi-level example


Sub-hashes can form deeper sub-hashes by stacking the "[ ]" terms in a row.


h6.URL parameters



search[user][id]=1


h6.JSON object



{
"search": {
"user": {
"id": 1
}
}
}


h4#array. Array


Arrays can be sent by appending an empty "[]" at the end of the final specifier for the key.


h5.Single-item example


h6.URL parameters



search[name][]=test


h6.JSON object



{
"search": {
"name": ["test"]
}
}


h5.Multi-item example


Multiple array items are sent by using the exact same key for each value in the array.


h6.URL parameters



search[id][]=1&search[id][]=2


h6.JSON object



{
"search": {
"id": [1, 2]
}
}


h5#array-of-files. Array of files


When sending an array of files, the parameter follows a similar format, although it is treated like a hash, where each key of the hash is the index of the file in the array, starting with 0. Since files require a multi-part format, it will look like something similar to the following.



--9cab1cceecb6c4f5634bcba0e89ee77c
Content-Disposition: form-data; name="upload[files][0]"; filename="6fe571c9df2912b1ae551045c2157240.jpg"
Content-Type: image/jpeg



h4. See also


* Help:Array syntax

* Help:Chaining syntax

* Help:API


h4#external-links. External links


[1] https://www.w3resource.com/JSON/structures.php

[2] https://www.w3schools.com/tags/ref_urlencode.ASP