djhvscf / bootstrap-table-flatJSON

Plugin to flat the JSON object. Extension for Bootstrap-table
MIT License
12 stars 7 forks source link

Feature request: flatSeparator option #6

Closed jtrumbull closed 9 years ago

jtrumbull commented 9 years ago

@djhvscf: I forked this repository and was going to create some PRs. Didn't want to get to far if this is something that you are working on -or did't want in the extension.

Was thinking it would be nice to give the end developer the option of which separator to use. I.e

$.extend($.fn.bootstrapTable.defaults, {
    flat: false,
    flatSeparator: "."
});

If i passed flatSeparator: "__", I could get results like:

[
    {
        "user__name": "jtrumbull",
        "user__mood": "bored",
        "user__array__0__key1": "a",
        "user__array__1__key1": "b",
        "user__array__3__key1": "c"
    },
    {...},
    {...}
]

There may be scenarios where . is not the best separator. Can't think of any, just accounting for it.