Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ilteoood/seqproto-schemify
Generate seqproto code from json schema
https://github.com/ilteoood/seqproto-schemify
Last synced: 2 months ago
JSON representation
Generate seqproto code from json schema
- Host: GitHub
- URL: https://github.com/ilteoood/seqproto-schemify
- Owner: ilteoood
- License: mit
- Created: 2023-12-17T13:23:01.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2024-09-18T00:08:18.000Z (4 months ago)
- Last Synced: 2024-11-01T11:51:32.625Z (2 months ago)
- Language: TypeScript
- Size: 164 KB
- Stars: 4
- Watchers: 2
- Forks: 1
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# seqproto-schemify
seqproto-schemify is an utility that aims to generate [seqproto](https://github.com/oramasearch/seqproto) serialization and deserialization code from a json schema.
## Usage
### Serialization
```javascript
import { serialize } from 'seqproto-schemify';
import { createSer } from 'seqproto'const jsonSchema = {
type: 'object',
properties: {
name: {
type: 'string'
},
age: {
type: 'integer'
}
}
};const serializer = serialize(jsonSchema);
const toSerialize = {
age: 1,
name: 'test'
};const resultBuffer = serializer(createSer(), toSerialize);
```### Deserialization
```javascript
import { deserialize } from 'seqproto-schemify';
import { createDes } from 'seqproto'const jsonSchema = {
type: 'object',
properties: {
name: {
type: 'string'
},
age: {
type: 'integer'
}
}
};const deserializer = deserialize(jsonSchema);
const arrayBuffer = ...
const result = deserializer(createDes(arrayBuffer));
```