Jsonstores.com offers free, secure JSON datastore on the cloud for small and intermediate business. Enter the email on jsonstores.com to get a unique JSON store endpoint. Sending HTTP requests to communicate with your JSON datastore. Send POST requests to store data, PUT and PATCH requests to modify data, DELETE to remove data, and GET to retrieve data.
The following codes will create an object with the type of 'user'. The new user's ID will be returned.
let xhr = new XMLHttpRequest()
let myObj = {name:"Steve Jobs", company:"Apple"};
xhr.addEventListener('load', () => {
if (xhr.readyState === 4 && xhr.status === 200) {
console.log(xhr.responseText)
}
})
let url = https://api.jsonstores.com/5679096778206781440wJqSH/user
xhr.open('POST', url, false)
xhr.send(JSON.stringify(myObj))
{"id":"1"}
The following codes will create an object with the type of 'user' with custom id.
let xhr = new XMLHttpRequest()
let myObj = {name:"Steve Jobs", company:"Apple"};
xhr.addEventListener('load', () => {
if (xhr.readyState === 4 && xhr.status === 200) {
console.log(xhr.responseText)
}
})
let url = https://api.jsonstores.com/5679096778206781440wJqSH/user/my-custom-id
xhr.open('POST', url, false)
xhr.send(JSON.stringify(myObj))
{"id":"my-custom-id"}
These code snippets will retrieve the user object using the id.
let xhr = new XMLHttpRequest()
xhr.addEventListener('load', () => {
if (xhr.readyState === 4 && xhr.status === 200) {
console.log(xhr.responseText)
}
})
let url = https://api.jsonstores.com/5679096778206781440wJqSH/user/1
xhr.open('GET', url ,false)
xhr.send()
{name:"Steve Jobs", company:"Apple"}
The following codes will update the user object.
let xhr = new XMLHttpRequest()
let myObj = {name:"Steve Jobs", company:"Apple Inc"};
xhr.addEventListener('load', () => {
})
let url = https://api.jsonstores.com/5679096778206781440wJqSH/user/1
xhr.open('PUT', url, false)
xhr.send(JSON.stringify(myObj))
The following codes will delete the user object.
let xhr = new XMLHttpRequest()
let url = https://api.jsonstores.com/5679096778206781440wJqSH/user/1
xhr.open('DELETE', url ,false)
xhr.send()
We follow the JSON PATCH standard to allow partial updates to a JSON document. It can be useful to avoid sending a whole document when only a part has changed. More details documents can be found on JSON PATCH.
[
{ "op": "replace", "path": "/name", "value": "Jone Doe" },
{ "op": "add", "path": "/hello", "value": ["world", "!"] },
{ "op": "remove", "path": "/company" }
]