Skip to content

Wishlist #65

@jwaterloo

Description

@jwaterloo

A common use case in web development is the need for flatten and unflatten functions, that is the ability to flatten a json object into a map of javascript assignment strings and vice versa.

{
"member1" : true,
"member2" : "Hello World",
"member3" : [1, {"member4" : 4, "member5" : 6.5}, 3]
}

into

prefix "whatever"

key = whatever.member1
value = true
key = whatever.member2
value = "Hello World"
key = whatever.member3[0]
value = 1
key = whatever.member1[1].member4
value = 4
key = whatever.member1[1].member5
value = 6.5
key = whatever.member3[2]
value = 3

function sighatures would be something like

map<string, json_primitive_that_insn't_object_or_array> flatten(json_object_or_array, symbol_name);
json_object_or_array unflatten(map<string, json_primitive_that_insn't_object_or_array>, symbol_name);

The type of the map would be string to a json primitive that isn't an object or an array.

The use case is that the keys in the map could be used as form field names. PHP and jQuery both are already doing this natively. Wouldn't it be nice if C++ had equal or better footing for web development.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions