Wednesday, 17 May 2017

How to convert POST form data to JSON object

if there any default functions that can convert a post form data string into json object ?

Here is an example

sendNotification=true&type=extended&additionalNotes=&returnToMainPage=true

As you can this is the format of POST form data. I need to convert it into JSON object

{
    "sendNotification": "true",
    "type": "extended",
    "additionalNotes": "",
    "returnToMainPage": "true"
}

Also it should handle arrays like this

blog.blogposts[1].comments  1
blog.blogposts[1].likes 12

I wonder how can I do this using existing tools and libraries. I know that I can write my own converter, but I guess there should a default one.

Thanks

IMPORTANT

I don't have a form, I need just convert the form data string.



via bxfvgekd

No comments:

Post a Comment