by Otto » Sun Feb 04, 2024 8:03 am
Hello Carlos,
Thank you for your help. The function is working fine as long as there are no dates in the DBF.
I am concerned about what happens if the DBF and JSON do not have the same structure. We also need an assigning part within this function. You should be able to assign a key/value pair from the hash you receive from JSON to a specific DBF column with the correct value.
Regarding the function `FW_DbfToJson()`, it is perfect for a test when programming with html.
However, we need a simpler function only to create the array strings for the json. When preparing a JSON for HTML, there can be styling, etc., as well. For example, if you have values and they are negative, you can present these in HTML in red instead of black.
Thus, you have the `do while/enddo` not passing parameters like `[bFor]`, `[bWhile]`, `[nNext]`, `[nRec]`, `[lRest]`.
Programming the loop and conditions is more readable, maintainable, and generally more understandable. I would leave it as is.
But the lines would be fine if you could create them with:
`addresponse(address->name, 'start/end/nil')`
The `addresponse` should include a `Val2Char()` function.
```
h['response'] += "{" + '"name":' + '"' + ALLTRIM(address->name) + '",'
h['response'] += '"street":' + '"' + ALLTRIM(address->street) + '",'
h['response'] += '"city":' + '"' + ALLTRIM(address->city) + '"},'
```
Best regards,
Otto
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club********************************************************************