An open API service indexing awesome lists of open source software.

https://github.com/xvezda/jowa

JavaScript Object notation for Web API
https://github.com/xvezda/jowa

javascript json web-api

Last synced: about 1 month ago
JSON representation

JavaScript Object notation for Web API

Awesome Lists containing this project

README

        

# jowa

## What is it for?

It's a specification and also a library designed to express values that cannot be represented in JSON as valid JSON, and to assist in receiving and using them through Web APIs.

## Examples

`/api/patterns/greet`
```json
{
"type": "RegExp",
"args": ["hello,? (\\w+)", "i"]
}
```

```ts
import { fromSchema } from 'jowa';

const greetSchema = await fetch('/api/patterns/greet').then(r => r.json());
const greetRegex = fromSchema(greetSchema);

console.log(greetRegex instanceof RegExp); // true

const [, userName] = 'Hello, Xvezda!'.match(greetRegex);

console.log(userName); // Xvezda
```