If you're doing JSON that's not totally ephemeral (not like sending a
few keystrokes for a live search JS widget is [1]), but something more
like returning information from a database, you could do JSON yet get a
little closer to some of the benefit of XML (like "what the heck is this
data that we found in a file, or as an attachment in our database") by
including a little metadata in the top level of the JSON.
Doing this metadata might also comfort engineers who care deeply about
systems, [2] and who are always reasoning about uncertainties like
possibilities and risks.
Such metadata can include a URL for the schema/documentation of the
message (which references different spec for the metadata envelope),
what software produced it, a timestamp, maybe what server produced it,
maybe a more-specific characterization of the content separate from the
schema but perhaps not implicit in the content (maybe request REST data,
or request URL), maybe there's an industry sector standard to reference
(much like some XML DTDs/schemas), maybe you have a data sensitivity
model or authorization model that's appropriate for tagging sensitivity
of messages, etc.
If you're working on a startup and moving fast, and there's no standards
yet, and you don't want to figure out metadata right now, you might just
decide to use a `write-foo-json-message` procedure everywhere, which
only leaves a placeholder for metadata in the JSON structure. When you
later can figure out metadata, that Racket procedure can get some new
required keyword arguments for necessary info (giving you compiler
errors until you visit each call site), though you'll still have to
search through the JS code, to see where you should be using the
metadata (but at least the more fragile JS code will keep working,
because you had the placeholder in the JSON there from the start).
[1] That might be a bad example of ephemeral today, with some of the
dotcom snoopers capturing and analyzing even fine-grained mouse move
events. :)
[2] I care, without being married to anything, but it's unsettling how
interesting mundanity of XML and JSON details can be, for a moment. :)
--
You received this message because you are subscribed to the Google Groups "Racket
Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.