I have an object like
{ "status": "success", "auth": { "code": "23123213", "name": "qwerty asdfgh" } }
I want to convert it to dot notation (one level) version like:
{ "status": "success", "auth.code": "23123213", "auth.name": "qwerty asdfgh" }
Currently I am converting the object by hand using fields but I think there should be a better and more generic way to do this. Is there any?
Note: There are some examples showing the opposite way, but i couldn't find the exact method.
Note 2: I want it for to use with my serverside controller action binding.
I wrote another function with prefix feature. I couldn't run your code but I got the answer. Thanks
https://github.com/vardars/dotize
You can use the NPM dot-object (Github) for transform to object to dot notation and vice-versa.
You can recursively add the properties to a new object, and then convert to JSON:
Here is a fix/hack for when you get
undefined
for the first prefix. (I did)