Stripping a JSON of extra characters in PHP
[email protected] (The Doctor) Wed, 1 Feb 2023 15:45:22 -0000 (UTC)
| Newsgroups | comp.lang.php |
|---|---|
| Organization | NetKnow News |
| Message-ID | <[email protected]> |
From https://developer.moneris.com/livedemo/checkout/preload_req/guide/dotnet
I need a JSON as follows:
{
"store_id":"moneris",
"api_token":"hurgle",
"checkout_id":"chkt5BF66neris",
"txn_total":"452.00",
"environment":"qa",
"action":"preload",
"token": [
{
"data_key": "abc123datakey1",
"issuer_id": "645sddfvdrt4tefd"
},
{
"data_key": "abc123datakey2",
"issuer_id": "645sddfvdrt4tefd"
},
{
"data_key": "abc123datakey3",
"issuer_id": "645sddfvdrt4tefd"
}
],
"ask_cvv":"Y"
"order_no":"",
"cust_id":"chkt - cust - 0303",
"dynamic_descriptor":"dyndesc",
"language":"en",
"recur":{
"bill_now":"true",
"recur_amount":"1.00",
"start_date":"2021-11-21",
"recur_unit":"month",
"recur_period":"1",
"number_of_recurs":"10"
},
"cart":{
"items":[
{
"url":"https:\/\/example.com\/examples\/item1.jpg",
"description":"One item",
"product_code":"one_item",
"unit_cost":"100.00",
"quantity":"1"
},
{
"url":"https:\/\/example.com\/examples\/item2.jpg",
"description":"Two item",
"product_code":"two_item",
"unit_cost":"200.00",
"quantity":"1"
},
{
"url":"https:\/\/example.com\/examples\/item3.jpg",
"description":"Three item",
"product_code":"three_item",
"unit_cost":"100.00",
"quantity":"1"
}
],
"subtotal":"400.00",
"tax":{
"amount":"52.00",
"description":"Taxes",
"rate":"13.00"
}
},
"contact_details":{
"first_name":"bill",
"last_name":"smith",
"email":"[email protected]",
"phone":"4165551234"
},
"shipping_details":{
"address_1":"1 main st",
"address_2":"Unit 2012",
"city":"Toronto",
"province":"ON",
"country":"CA",
"postal_code":"M1M1M1"
},
"billing_details":{
"address_1":"1 main st",
"address_2":"Unit 2000",
"city":"Toronto",
"province":"ON",
"country":"CA",
"postal_code":"M1M1M1"
}
}
But in testng I am getting
[{"store_id":"store3","api_token":"yesguy","checkout_id":"chkt23NGFtore3","txn_total":"126.00","environment":"qa","action":"preload"},[{"cart":[[[{"items":{"url":"https:\/\/www.pdsolutions.ca\/images\/newwhiteheader.png","description":"Agricultural Health Study","product_code":"AHS-1298","unit_cost":60,"quantity":"1"},"subtotal":60,"tax":{"amount":3,"description":"GST","rate":"0.05"}},{"items":{"url":"https:\/\/www.pdsolutions.ca\/images\/newwhiteheader.png","description":"Pesticide Applicator Records","product_code":"PAR-1302","unit_cost":60,"quantity":"1"},"subtotal":60,"tax":{"amount":3,"description":"GST","rate":"0.05"}}]]]}],[{"contact_details":{"first_name":"Dave","last_name":"Yadallee","email":"[email protected]","phone":"7809999999"}}],[{"billing_details":{"address_1":"","city":"","province":"","country":"CA","postal_code":""}}]]
How can I carefully strip unnecessary punctuation?
--
Member - Liberal International This is [email protected] Ici [email protected]
Yahweh, King & country!Never Satan President Republic!Beware AntiChrist rising!
Look at Psalms 14 and 53 on Atheism https://www.empire.kred/ROOTNK?t=94a1f39b
When they offer free stuff, demand to know how much it will cost. -unknown Beware https://mindspring.com