×
The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.
Jon,
I agree that the 2nd design doesn't make much sense. Are you certain it
didn't look like this?
{
"product": {
"Loveseat": 395.99,
"Sofa": 1159.99
}
}
That would be, perhaps, the most efficient way to do it -- and the most
logical way in many programming languages (much better than your
"productname" and "price" design).
However, it really doesn't work with DATA-INTO. But, 99.9% of people
working with JSON aren't using DATA-INTO (since they're not RPG shops)
so it's easy to see why.
What we have above is essentially a look up table... very much like what
we can do with %LOOKUP in RPG, or a keyed file with the CHAIN opcode.
In languages like JavaScript, Python, or PHP you'd simply do:
price = myJson.product[key];
If key="Loveseat" you'd get 395.99, if key="Sofa" you'd get 1159.99.
Super easy, performs extremely well... it's an excellent interface
design, as long as you're not using DATA-INTO :-)
-SK
On 7/20/23 9:56 AM, Jon Paris wrote:
Nasty.
The nastiest one I encountered was one where they basically made up the data names based on the query. If the query (for example) returned two products then instead of an array of data containing something like:
{
"product": [{
"productname": "Loveseat",
"price": 395.99
},
{
"productname": "Sofa",
"price": 1159.99
}
]
}
It would instead be:
{
"product": [{
"Loveseat": 395.99
},
{
"Sofa": 1159.99
}
]
}
Bad enough by itself but a similar system was used for other features. Truly horrible "design".
In the JSON world, there seems to be rather too much of a "because we can" attitude.
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact
[javascript protected email address].
Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.