fold
fold
function converts a JSON object into key-value pair object by folding it.
Arguments
-
object
type:
object
The JSON object to fold.
e.g.
{ a: { b: "c" } }
will be folded to{ "a.b": "c" }
. -
option
type:
object
-
arrayIndex
type:
"dot" | "bracket"
default:
"bracket"
The index of array to fold.
e.g.
{ a: ["b"] }
will be folded to{ "a[0]": "b" }
ifarrayIndex
is"bracket"
, and will be folded to{ "a.0": "b" }
ifarrayIndex
is"dot"
. -
keyPrefix
type:
string
default:
""
The prefix to prepend to the folded key.
-