views:

39

answers:

1

I'm looking for opinions on whether microformats should be used to name JSON elements. For instance, there is a microformat for physical addresses, that looks like this:

<div class="adr">
    <div class="street-address">665 3rd St.</div>
    <div class="extended-address">Suite 207</div>
    <span class="locality">San Francisco</span>,
    <span class="region">CA</span>
    <span class="postal-code">94107</span>
    <div class="country-name">U.S.A.</div>
</div>

There is a document available on using JSON and Microformats. The information above could be represented as JSON data like this:

"adr": {
    "street-address":"665 3rd St.",
    "extended-address":"Suite 207",
    "locality":"San Fransicso",
    "region":"CA",
    "postal-code":"94107",
    "country-name":"U.S.A."
},

The issue I have with this is that I'd like my JSON data to be as lightweight as possible, but still human readable. While still supporting international addresses, I would prefer something like this:

"address": {
    "street":"665 3rd St.",
    "extended":"Suite 207",
    "locality":"San Fransicso",
    "region":"CA",
    "code":"94107",
    "country":"U.S.A."
},

If I'm designing a new JSON API right now, does it make sense to use microformats from the start? Or should I not really worry about it? Is there some other standard that is more specific to JSON that I should look at?

A: 

This comes down to a matter of personal choice for a simple reason. The difference using your sample data is approx. 192 bits of data. At this point your process/transfer difference is negligible.

If it's an internal API then your suggested method is more than adequate. It easily identifies each section tersely while still being descriptive. However, if the API is something that you plan on opening up to the public, I would suggest the staying with the micro-format.

Angelo R.
@Angelo: Thanks, I appreciate your feedback. Sure the difference is small for one record. But when I'm sending sets of 50 or 100 at a time to thousands of users, it can add up. My API will not initially be open to the public, but it probably will in the future, which is why I was looking into microformats to begin with.
Tauren
Ah alright, I suppose the only other major player that would utilize a standard address naming convention would be Google Maps, which uses xAL http://www.oasis-open.org/committees/ciq/ciq.html#6 Although their format would add a lot more overhead to your issue. Personally, I would still go with the micro-format. If you are opening it to the public having a standard way of pushing the data to them means an easier learning curve. Users that are already familiar with the micro-format won't have an issue and users that aren't will find it just as easy.
Angelo R.