Senthurkumaran
Senthurkumaran

Reputation: 1858

How to convert below JSON data to application/x-www-form-urlencoded?

I want to convert below JSON data to x-www-form-urlencoded format. How can do that in JavaScript? or else any online converter?

    stripe_data: {
          "type" : "card",
          "billing_details" : {
              "name" : "sample test",
              "email" : "[email protected]",
              "phone" : "+61 76 253 4125",
              "address" : {
              "state" : "Melborne",
              "country" : "Australia"
              }
          },
          "card" : {
              "number" : "4242424242424242",
              "cvc" : "242",
              "exp_month" : "01",
              "exp_year" : "22"
          }
        }

I searched google but i didn't find any solution for this type of data (object into object).

Upvotes: 1

Views: 1206

Answers (1)

Senthurkumaran
Senthurkumaran

Reputation: 1858

I solved above problem using JavaScript package called qs. I am working in Nuxt.js and using npm so i give answer through that point First install using npm run qs then in your code import qs like import qs from 'qs' then use where ever you want like qs.stringify(data) // data - JSON format

Upvotes: 1

Related Questions