Re: Stripping a JSON of extra characters in PHP
Arno Welzel <[email protected]> Tue, 7 Feb 2023 09:13:47 +0100
| Newsgroups | comp.lang.php |
|---|---|
| Message-ID | <[email protected]> |
The Doctor, 2023-02-07 01:57: > In article <[email protected]>, > Arno Welzel <[email protected]> wrote: >> The Doctor, 2023-02-06 16:28: >> >> [...] >>> The cart is being derived from a previous form being passed into PHP! >> >> [...] >>> $arr=array( >>> 'store_id' => "store3", >>> 'api_token' => "yesguy", >>> 'checkout_id' => "chktGLFZQtore3", >>> 'txn_total' => $_POST['charge_total'], >>> 'environment' => "qa", >>> 'action' => "preload", >>> 'cart' => array( >>> (foreach ($_POST['quantity'] as $key => $value) { >> >> Well - this will result in an array in the JSON named "cart". >> >>> $cart['items'][] =array( >> >> And this will also become an array named "items" inside "cart". >> >> So if you don't want "cart" to be an array in the JSON, then don't >> create it this way. >> >> Learn how to read JSON and that the "punctuation" are not just >> characters but have a specific meaning. In this case you created an >> array and the JSON will have an array as well - indicated by "[" and "]". >> > > Again basing this on Moneris prereqs. What is "Moneris prereqs"? Your OP was: "How can I carefully strip unnecessary punctuation?" I tried to explain to you, where these "punctuation" comes from. But if you don't accept the facts, then you have to live with it. -- Arno Welzel https://arnowelzel.de