wissel.net

Usability - Productivity - Business - The web - Singapore & Twins

Progress in data structures


Four decades ago COBOL ruled business IT. Its DATA DIVISION. contained all the data structures we ever would need. COBOL had clever constructs like REDEFINES and (in the procedure division) MOVE CORRESPONDING. Of course during the last fourty years we made progress. COBOL data was un-throned by XML (OK I skipped some steps in between) which is getting un-throned by JSON. Comparing the formats you clearly can see the progress made:

COBOL

        DATA DIVISION .
            01 Customer .
              02 Name .
                  03 Lastname   PIC A ( 40 ) .
                  03 Firstname   PIC A ( 20 ) .
              02 Address .
                  03 Street     PIC X ( 25 ) .
                  03 Street2   PIC X ( 25 ) .        
                  03 City       PIC X ( 25 ) .
                  03 Zipcode .
                    04 Zipbase       PIC 9 ( 5 ) .
                    04 Zipextension   PIC 9 ( 4 ) .
              02 DOB .
                  03 Month   PIC 99 .
                  03 Day     PIC 99 .
                  03 Year   PIC 9999 .

XML

<Customer>
    <Name>
      <Lastname />
      <Firstname />
    </Name>
    <Address>
      <Street />
      <Street2 />
      <City />
      <Zipcode>
        <Zipbase />
        <Zipextension />
      </Zipcode>
    </Address>
    <DOB>
      <Month />
      <Day />
      <Year />
    </DOB>
</Customer>

JSON

function Customer ( ) {
    "Name"     : {
                  "Lastname" ,
                  "Firstname"
                } ,
     
    "Address" : {
                  "Street" ,
                  "Street2" ,
                  "City" ,
                  "Zipcode" {
                              "Zipbase" ,
                              "Zipextension"
                        }
            } ,

    "DOB"     : {
                  "Month" ,
                  "Day" ,
                  "Year"
                }
}

Now can someone explain how to do a redefines or a move corresponding in JSON?

Posted by on 17 October 2010 | Comments (3) | categories: After hours Software

Comments

  1. posted by Ethann Castell on Monday 18 October 2010 AD:
    I'm not sure that you're really old enough to remember COBOL :)

    I'm not so sure about JSON un-throning XML though. Maybe in the browser but I don't see it happening elsewhere.
  2. posted by Craig Wiseman on Wednesday 20 October 2010 AD:
    My personal theory is that since a woman wrote the spec for COBOL, it means two things:

    + it still works well today, and;

    + men have been trying to out do her ever since.

    Emoticon biggrin.gif
  3. posted by John Foldager on Wednesday 27 October 2010 AD:
    @2.... Emoticon biggrin.gif

    @Stephan, your XML and JSON are not well-formed... as you probably know. But I think that for future reference others should know too... so here goes...

    XML should always start with a prolog like so:

    <?xml version='1.0' encoding='utf-8' ?>
    <Customer>
    :
    </Customer>

    ...where version and encoding are optional but highly recommended.

    As for your JSON example it does in fact give a JSON object when called from JavaScript, bit the source is not JSON as JSON does not contain 'function' which (I guess) is a JavaScript function you are refering to. So the syntax of JSON would be (as an JSON object):

    {
    "Customer": {
    "Name" : {
    :
    "DOB" : {
    :
    }
    }
    }

    ...or (as an JSON array of a single object in this case)...

    [{
    "Customer": {
    "Name" : {
    :
    "DOB" : {
    :
    }
    }
    }]

    Emoticon cool.gif

    For answering your question regarding Cobol.... well... hmm.... arghh.... I guess I'm too young Emoticon biggrin.gif