- Feature Articles
- CodeSOD
- Error'd
-
Forums
-
Other Articles
- Random Article
- Other Series
- Alex's Soapbox
- Announcements
- Best of…
- Best of Email
- Best of the Sidebar
- Bring Your Own Code
- Coded Smorgasbord
- Mandatory Fun Day
- Off Topic
- Representative Line
- News Roundup
- Editor's Soapbox
- Software on the Rocks
- Souvenir Potpourri
- Sponsor Post
- Tales from the Interview
- The Daily WTF: Live
- Virtudyne
Admin
If they need to treat the subdocument as a blackbox and properly encode it and decode it, what is wrong with that?
Admin
I was in the process of doing basically the same, but it was late at night and I was on Ibuprofen AND I stopped myself BECAUSE it felt so stupid. Then I did the sub-object approach.
Admin
WTF, I just encountered the same thing yesterday. Was thinking of sending it in...
{
"result": "{"result": [{"interview_id": "996395", }",
Admin
There are two things in the world I can't stand: JSON strings in JSON... and the Dutch.
(I'm pretty sure begin_datum and eind_datum are Dutch, even though they are misspelled).
Edit Admin
I mean, they could have embedded XML as a string inside of a JSON, so this isn't the worst?
Admin
Both are correctly spelled in Dutch, yes. So, most likely a Dutch interface.
Admin
Better than the industrial IOT device I had to deal with recently. Their website: "In addition to a custom binary wire protocol, we support sending measurements as JSON via MQTT". The JSON:
{ "data": "0x......." }
Admin
I haven't encountered this, but I have encountered xml encoded as an xml string. Biggest surprise was that they didn't also base64 encoded it.
Edit Admin
Yes, that's Dutch. Not misspelled, but you can argue about snake_casing in json.
Admin
"begindatum" and "einddatum" are one word. No spaces, no underscores, no hyphens. But the end point won't care, of course.
Edit Admin
If they are using JSON references, then they might have issues just embedding one JSON document within another. In that case coding as a string is a "reasonable" work-around.
Admin
To be fair, if the embedded JSON is from some place notorious for hand-crafting broken JSON strings, this is a good way to hand it over without having to deal with the embedded idiosyncracies.
Admin
Could be worse. You could have a Base64 nonce that, when decoded, contains a JSON object with two keys, which are also Base64 strings... of JSON.
eyJiIjp7IkN1cnNvciI6ImV5SnpJam8yTVRJeE9DNDFPREEyTmpRMU5UazROeXdpWkNJNlptRnNjMlVzSW5RaU9uUnlkV1Y5In0sImEiOnsiQ3Vyc29yIjoiZXlKeklqbzVOamczTGpFMk9URTNNamsyTVRnek5Dd2laQ0k2Wm1Gc2MyVXNJblFpT25SeWRXVjkifX0
Admin
That's how you do it: https://thedailywtf.com/articles/edoced-46esab
Edit Admin
I see embedded JSON like this all the time in Stack Overflow questions. It's unfortunately too common.
Edit Admin
Could be worse. They could have included comments. And encoded comments in the embedded json.
(Put the keyboard down. I am aware that the json spec doesn't support comments. That's the joke.)
Edit Admin
Another "Me Too" here - a system we use does that for the interface to run custom functions.
Edit Admin
Banking applications are notorious for using XML. I had a finance client that used a service that took it one step further. What was essentially an XML-RPC call (although following their own conventions) turned the inner data into an XML handshake sequence. Then, an outer "transport layer" was used for session management. It took the inner conversation's payloads and added an entirely new level of XML. Yes, double encoded everythings. And it didn't handle CDATA properly so I couldn't even use that. Ugh. (This came about because a large bank-networking company had purchased a smaller bank-networking company, and they had to support both layers of interface.)
Admin
May previous place of work used XML embedded in JSON, which was then embedded in an XML document for it's API.
Each of which took the anti pattern of having a "success" attribute that needed to be checked in case something fell over(because returning a HTTP error is too complicated).
The reasoning was that they started with a poorly defined XML API, then decided JSON was better since they had no advantages from XML anyway and migrated basically nothing to it instead just wrapping up the old responses in a JSON wrapper. Then a few years down the line decided they should move back to XML so they could use custom doctypes to define the response/request format, so they moved back, but again swapping things over fully was too much like hard work so most of the APIs just got wrapped in a new XML layer.
Giving us wonderful API responses like
Edit Admin
I hate you.
Edit Admin
I hate it, but it's so common I don't even think of it as a WTF anymore...
Edit Admin
It's positively horrifying
Admin
Well it's nice to see that not only XML allows for inception .. (ref https://thedailywtf.com/articles/double-bagged )
Yazeran
Edit Admin
Reckon says, "Hold my beer!" :P
I don't know if Intuit went that way with Quickbooks itself, but Reckon certainly decided to wrap the QBXML in a JSON request.