Re: Stripping a JSON of extra characters in PHP
"J.O. Aho" <[email protected]> Fri, 10 Feb 2023 11:49:57 +0100
| Newsgroups | comp.lang.php |
|---|---|
| Message-ID | <[email protected]> |
On 2/9/23 22:01, The Doctor wrote: > In article <[email protected]>, > Arno Welzel <[email protected]> wrote: >> Sorry - but if you are really not able to understand what I write, you >> should pay someone to do the job for you. > > The problem is the way the supplier wants to oush the information. You need to follow the api requierment which says that the json should have an array of json objects, not an array of arrya with array. Your task is to take the posted value convert it to be in the format that the api requiers. Using classes will make the code more readable and you can break things up into smaller chunks when you are writing your code. I think it's beter to transform things into a variable and then assing it to the object's variable to make the assignment clear and simple. Don't forget that the classes can include arrays, but only use those in the places where you need it, IMHO it can be sometimes good to iniate the array in the class constructor (this only can be done as long as the api don't require the array to be omitted if no values). Don't forget that the company providing the API also has a support team which can help, sure it may come with a cost, depending on the deggree of help and how much they think is out of topic. For them it's importnat to earn money and if they think helpiing you will give them enough money in return, they may help more than they normal support is mandated to do. -- //Aho