JSPM

json-qs-converter

1.0.1
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 4
  • Score
    100M100P100Q21388F
  • License ISC

Convert a json to a string for use in a GET request.

Package Exports

  • json-qs-converter
  • json-qs-converter/index.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (json-qs-converter) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

json-qs-converter

json-qs-converter It is a method that allows to transform a json object to a valid string to be used in a GET request.

Install

npm install json-qs-converter

Usage

Its use is very simple, just import the method and pass the json object as a parameter to obtain the string.

const qs = require('json-qs-converter')

const obj = { group: 'category' }
const obj2 = { projects: { new_total: 1 } }
const obj3 = { projects: { new_total: ['qty', { multiply: [2, 2] }] } }
const obj4 = { projects: { new_total: 1 }, sum: { projects: { new_total: ['qty', { multiply: [2, 2] }] } } }

let str = qs(obj) // => ?group=category

str = qs(obj2) // => ?projects[new_total]=1

str = qs(obj3) // => ?projects[new_total]=qty&projects[new_total][1][multiply]=2&projects[new_total][1][multiply]=2

str = qs(obj2) // => ?projects[new_total]=1&sum[projects][new_total]=qty&sum[projects][new_total][1][multiply]=2&sum[projects][new_total][1][multiply]=2

Note

The method does not yet support multidimensional arrays.