JsonDB: Universal Integration Without Special Libraries

In the world of modern application development, flexibility is key. Yet many database solutions lock you into specific ecosystems or require dedicated libraries. JsonDB takes a different approach, offering truly universal integration through standard HTTP requests.

One API, Endless Possibilities

Perfect for single-page applications and mobile apps, but also works seamlessly with curl, Postman, and testing frameworks. JsonDB is a versatile solution for all your JSON storage needs.

The beauty of JsonDB lies in its simplicity - if your programming language can make HTTP requests, you can use JsonDB. No special libraries, SDKs, or dependencies required.

Integration Examples Across Languages

Let's see how easy it is to work with JsonDB in various environments:

Command Line with cURL

# Store data
curl -X POST https://jsondb.rest/api/v1/ \
  -H "Content-Type: application/json" \
  -d '{"hello": "world"}'

# Retrieve data
curl https://jsondb.rest/api/v1/0196cb73-4363-7001-8e42-5541629d388f.json
  

Command Line with HTTPie

# Store data
http POST https://jsondb.rest/api/v1/ hello=world

# Retrieve data
http GET https://jsondb.rest/api/v1/0196cb73-4363-7001-8e42-5541629d388f.json
  

JavaScript (Browser) with Fetch API

// Store data
fetch('https://jsondb.rest/api/v1/', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({ hello: 'world' })
})
.then(response => response.json())
.then(data => console.log('Success:', data))
.catch(error => console.error('Error:', error));

// Retrieve data
fetch('https://jsondb.rest/api/v1/0196cb73-4363-7001-8e42-5541629d388f.json')
.then(response => response.json())
.then(data => console.log('Data:', data))
.catch(error => console.error('Error:', error));
  

JavaScript (Node.js) with Axios

const axios = require('axios');

// Store data
axios.post('https://jsondb.rest/api/v1/', {
  hello: 'world'
})
.then(response => console.log('Success:', response.data))
.catch(error => console.error('Error:', error));

// Retrieve data
axios.get('https://jsondb.rest/api/v1/0196cb73-4363-7001-8e42-5541629d388f.json')
.then(response => console.log('Data:', response.data))
.catch(error => console.error('Error:', error));
  

Python with Requests

import requests
import json

# Store data
response = requests.post(
    'https://jsondb.rest/api/v1/',
    headers={'Content-Type': 'application/json'},
    data=json.dumps({'hello': 'world'})
)
print('Success:', response.json())

# Retrieve data
response = requests.get('https://jsondb.rest/api/v1/0196cb73-4363-7001-8e42-5541629d388f.json')
print('Data:', response.json())
  

PHP with cURL

<?php
// Store data
$data = array('hello' => 'world');
$ch = curl_init('https://jsondb.rest/api/v1/');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json'));
$response = curl_exec($ch);
curl_close($ch);
echo 'Success: ' . $response;

// Retrieve data
$ch = curl_init('https://jsondb.rest/api/v1/0196cb73-4363-7001-8e42-5541629d388f.json');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
curl_close($ch);
echo 'Data: ' . $response;
?>
  

C# (.NET)

using System;
using System.Net.Http;
using System.Text;
using System.Threading.Tasks;
using System.Text.Json;

class Program
{
    static async Task Main()
    {
        using (var client = new HttpClient())
        {
            // Store data
            var data = new { hello = "world" };
            var content = new StringContent(
                JsonSerializer.Serialize(data),
                Encoding.UTF8,
                "application/json");
                
            var response = await client.PostAsync(
                "https://jsondb.rest/api/v1/",
                content);
                
            Console.WriteLine($"Success: {await response.Content.ReadAsStringAsync()}");
            
            // Retrieve data
            var getResponse = await client.GetAsync(
                "https://jsondb.rest/api/v1/0196cb73-4363-7001-8e42-5541629d388f.json");
                
            Console.WriteLine($"Data: {await getResponse.Content.ReadAsStringAsync()}");
        }
    }
}
  

Java with HttpClient (Java 11+)

import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;

public class JsonDBExample {
    public static void main(String[] args) throws Exception {
        HttpClient client = HttpClient.newHttpClient();
        
        // Store data
        String jsonData = "{\"hello\": \"world\"}";
        HttpRequest postRequest = HttpRequest.newBuilder()
            .uri(URI.create("https://jsondb.rest/api/v1/"))
            .header("Content-Type", "application/json")
            .POST(HttpRequest.BodyPublishers.ofString(jsonData))
            .build();
            
        HttpResponse<String> postResponse = client.send(
            postRequest, 
            HttpResponse.BodyHandlers.ofString());
            
        System.out.println("Success: " + postResponse.body());
        
        // Retrieve data
        HttpRequest getRequest = HttpRequest.newBuilder()
            .uri(URI.create("https://jsondb.rest/api/v1/0196cb73-4363-7001-8e42-5541629d388f.json"))
            .GET()
            .build();
            
        HttpResponse<String> getResponse = client.send(
            getRequest,
            HttpResponse.BodyHandlers.ofString());
            
        System.out.println("Data: " + getResponse.body());
    }
}
  

D Language

import std.net.curl;
import std.stdio;
import std.json;

void main()
{
    // Store data
    auto jsonData = JSONValue(["hello": JSONValue("world")]);
    auto http = HTTP();
    http.addRequestHeader("Content-Type", "application/json");
    auto postResponse = post(
        "https://jsondb.rest/api/v1/",
        jsonData.toString(),
        http
    );
    writeln("Success: ", postResponse);
    
    // Retrieve data
    auto getResponse = get(
        "https://jsondb.rest/api/v1/0196cb73-4363-7001-8e42-5541629d388f.json"
    );
    writeln("Data: ", getResponse);
}
  

Julia

using HTTP
using JSON

# Store data
data = Dict("hello" => "world")
response = HTTP.post(
    "https://jsondb.rest/api/v1/",
    ["Content-Type" => "application/json"],
    JSON.json(data)
)
println("Success: ", String(response.body))

# Retrieve data
response = HTTP.get("https://jsondb.rest/api/v1/0196cb73-4363-7001-8e42-5541629d388f.json")
println("Data: ", String(response.body))
  

Seamless Testing Integration

JsonDB's universal compatibility makes it an ideal solution for testing environments. Since it requires no special libraries and works with standard HTTP requests, it integrates effortlessly with all major testing frameworks.

Perfect for Unit Tests

In unit tests, you often need a lightweight data store that doesn't require complex setup. JsonDB provides exactly that - a simple HTTP endpoint that can be mocked or used directly in your tests. No need to configure complex database connections or worry about test data cleanup.

// Example Jest test with JsonDB
test('saves and retrieves user data', async () => {
  // Store test data
  const userData = { name: 'Test User', email: 'test@example.com' };
  const saveResponse = await axios.post('https://jsondb.rest/api/v1/', userData);
  const docId = saveResponse.data.id;
  
  // Retrieve and verify
  const getResponse = await axios.get(`https://jsondb.rest/api/v1/${docId}.json`);
  expect(getResponse.data).toEqual(userData);
});
  

Ideal for End-to-End Testing

End-to-end tests often struggle with database state management. With JsonDB, you can easily:

  1. Set up test data with a simple POST request
  2. Run your tests against real data
  3. Clean up afterward with a DELETE request

This approach works with Cypress, Playwright, Selenium, or any other E2E testing tool that can make HTTP requests - which is all of them!

By eliminating the need for database-specific libraries and configuration, JsonDB removes a major pain point in the testing process. Your tests become more portable, easier to maintain, and faster to run.

Conclusion

JsonDB's universal integration capabilities make it not just a database, but a versatile tool in your development arsenal. Whether you're building a complex application or setting up quick tests, the standard HTTP interface provides the flexibility you need without the overhead of special libraries or complex configuration.

Start integrating JsonDB today and experience the freedom of truly universal JSON storage.

🔙 Back to blog

Follow us on X and GitHub for updates.

Made with ❤️ by @jsondbcloud team. Powered by the jsondb.cloud API - Simple JSON storage up to 10KB. No backend setup required, just upload and use your JSON anywhere.

We are NOT the JsonDB: a Opensource, Java-based, Database. Name is coincidental. Happens. There may be more similar names out there. But none of them are as cool and great as this one.