UNPKG

json-order

Version:

Control the order of properties in JSON via a lookup object - including nested properties.

13 lines (12 loc) 924 B
import { PropertyMap } from './models'; /** * Stringify a JS object while maintaining a particular property order: * * @param sourceObject an object with the properties in any order * @param map the `PropertyMap` generated by the `parse` method. * @param separator a non-empty `string` that controls what the key separator is in the generated map. Defaults to `~`. * @param space a `number` used to insert white space into the output JSON string for readability purposes, as per the `JSON.stringify` [documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify#Parameters) * @returns the stringified source object ordered as per the map. If the map is unset, the response is a standard `JSON.stringify`. */ declare const stringify: (sourceObject: object, map: PropertyMap | null, separator?: string, space?: number | undefined) => string; export default stringify;