Format schema object to a string in JSON format and viceversa
npm i
npm run build
npm i @btime/query-string-adapter -S
- Input:
const QueryStringAdapter = require('@btime/query-string-adapter')
const data = {
filters:
{
active: true,
deleted: false,
service_status_id: [1, 2]
},
fields:
{
service: ['name'],
service_type_id: 'bank'
},
paginate:
{
page: 2,
limit: 25
},
ordination:
{
field: 'name',
type: 'DESC'
}
}
const parsed = QueryStringAdapter.parse(data)
- Output:
{
"filters":
{
"active": true,
"deleted": false,
"service_status_id": [1, 2]
},
"fields":
{
"service": ["name"],
"service_type_id": "bank"
},
"paginate":
{
"page": 2,
"limit": 25
},
"ordination":
{
"field": "name",
"type": "DESC"
}
}
- Input:
const QueryStringAdapter = require('@btime/query-string-adapter')
const data = '{"filters":{"active":true,"deleted":false,"service_status_id":[1,2]},"fields":{"service":["name"],"service_type_id":"bank"},"paginate":{"page":2,"limit":25},"ordination":{"field":"name","type":"DESC"}}'
const parsed = QueryStringAdapter.parse(data)
- Output:
{
filters:
{
active: true,
deleted: false,
service_status_id: [1, 2]
},
fields:
{
service: ['name'],
service_type_id: 'bank'
},
paginate:
{
page: 2,
limit: 25
},
ordination:
{
field: 'name',
type: 'DESC'
}
}