• The Four Hundred
  • Subscribe
  • Media Kit
  • Contributors
  • About Us
  • Contact
Menu
  • The Four Hundred
  • Subscribe
  • Media Kit
  • Contributors
  • About Us
  • Contact
  • Meet JSON

    November 9, 2011 Alex Roytman

    If you have done Web application development with any modern toolset or technology lately, you have undoubtedly run across a trusty friend of mine: JSON (pronounced Jason). In recent years, JSON, or JavaScript Object Notation, has become the data interchange format of choice for Web applications. It has allowed many Web frameworks to flourish and has tremendously simplified my own job of creating IBM i web applications and frameworks. That’s why I decided to write a series of articles on JSON, in which I will explain the what, the why, and the how of JSON in detail.

    Let’s get going!

    JSON is a data interchange format. Instead of starting out with a boring textbook definition for JSON, let’s compare it to something you are probably already familiar with. Prior to JSON, one of the most common ways to exchange data in Web applications was through the use of XML. Since everyone has heard of XML, I like to define JSON as an alternative to XML that is intentionally made simple to use in Web applications. That is, when storing and exchanging data, we can use a format that is easier to process in the Web browser.

    JSON is mostly relevant when used with true browser applications, that is, applications that use an HTML or a Rich DHTML (Dynamic HTML) front-end. If a Web application runs in an Applet, ActiveX Control, or Flash object, JSON will not help much, since these are all browser add-ons.

    To get a feel for why JSON is such a good fit for true browser applications, let’s dissect the acronym for JavaScript Object Notation. The first part, JavaScript, refers to the browser’s built-in client-side language. The importance of JavaScript in Web application development cannot be underestimated. JavaScript is the only high-level language that the browser understands natively. If any exchange or processing of data is going to happen, JavaScript is most likely to be involved. This is especially true in recent years, where a technique called AJAX has become the predominant way to initiate most client-server communication from the Web browser. AJAX allows JavaScript to call the server for bits of data, instead of reloading the entire browser page with every user interaction.

    Let’s now look at a typical interaction between a user and the browser.

    • A user enters a customer number and clicks a button to see a list of customer orders.
    • The browser, through the use of JavaScript and AJAX, sends a request to the IBM i for a list of customer orders.
    • IBM i runs server-side code, typically RPG or PHP, to produce the list to send back as a response.
    • The browser receives the response from the IBM i and renders the list of orders on the page.

    At its core, the generated response is really just a string of data, or a stream of bytes, sent through the HTTP server back to the browser. It could be formatted in any way–comma delimited data, EDI-style fixed width chunks, or XML. The preferred way, however, is a format permeated with brackets and curly braces that we call JSON.

    Which brings me to the second acronym, Object Notation. You may have heard that JavaScript is loosely typed and has fairly flexible syntax. Object Notation refers to the syntax in JavaScript that allows you to declare objects (also thought of as records or data structures) and arrays on the fly. Here is what the order list response may look like:

    [ { "order_num": 1, "ship_to_location": "Dayton, OH", "total_amount": 308.29 }, 
    { "order_num": 2, "ship_to_location": "Irvine, CA", "total_amount": 456.50 }, 
    { "order_num": 3, "ship_to_location": "Rochester, MN", "total_amount": 56.00 } ]
    

    Don’t worry about the syntax details just yet. But do realize that this is as native as it gets when it comes to representing data for JavaScript. JSON is the only format that doesn’t have to be parsed by the extra client-side code. It is automatically evaluated and consumed without any special parsing! In this case, when the PHP or RPG program sends the above string of data, an array of orders is automatically created on the client-side. Each order is represented by a JavaScript object, which is similar to a record in RPG. Now, the browser can proceed to render the data on the screen, without any other processing or delay. And that’s the beauty of the JSON format!

    I hope this served as a good introduction to JavaScript Object Notation. But there is a lot more to discuss! We will dive into more details on how JSON is constructed, received, processed, debugged, and how JSON can present a graphical user interface for RPG applications in coming articles.



                         Post this story to del.icio.us
                   Post this story to Digg
        Post this story to Slashdot

    Share this:

    • Reddit
    • Facebook
    • LinkedIn
    • Twitter
    • Email

    Tags:

    Sponsored by
    DRV Tech

    Get More Out of Your IBM i

    With soaring costs, operational data is more critical than ever. IBM shops need faster, easier ways to distribute IBM applications-based data to users more efficiently, no matter where they are.

    The Problem:

    For Users, IBM Data Can Be Difficult to Get To

    IBM Applications generate reports as spooled files, originally designed to be printed. Often those reports are packed together with so much data it makes them difficult to read. Add to that hardcopy is a pain to distribute. User-friendly formats like Excel and PDF are better, offering sorting, searching, and easy portability but getting IBM reports into these formats can be tricky without the right tools.

    The Solution:

    IBM i Reports can easily be converted to easy to read and share formats like Excel and PDF and Delivered by Email

    Converting IBM i, iSeries, and AS400 reports into Excel and PDF is now a lot easier with SpoolFlex software by DRV Tech.  If you or your users are still doing this manually, think how much time is wasted dragging and reformatting to make a report readable. How much time would be saved if they were automatically formatted correctly and delivered to one or multiple recipients.

    SpoolFlex converts spooled files to Excel and PDF, automatically emailing them, and saving copies to network shared folders. SpoolFlex converts complex reports to Excel, removing unwanted headers, splitting large reports out for individual recipients, and delivering to users whether they are at the office or working from home.

    Watch our 2-minute video and see DRV’s powerful SpoolFlex software can solve your file conversion challenges.

    Watch Video

    DRV Tech

    www.drvtech.com

    866.378.3366

    Share this:

    • Reddit
    • Facebook
    • LinkedIn
    • Twitter
    • Email

    Sponsored Links

    Shield Advanced Solutions:  Access IBM i data & objects from Linux & Windows Servers using PHP
    Dan Riehl Presents:  Fall Training Sale – Discounts up to 40%! RPG IV COBOL CL Admin Security
    ProData Computer Services:  Learn how to access remote data -- RDB Connect On-Demand Webinar

    IT Jungle Store Top Book Picks

    BACK IN STOCK: Easy Steps to Internet Programming for System i: List Price, $49.95

    The iSeries Express Web Implementer's Guide: List Price, $49.95
    The iSeries Pocket Database Guide: List Price, $59
    The iSeries Pocket SQL Guide: List Price, $59
    The iSeries Pocket WebFacing Primer: List Price, $39
    Migrating to WebSphere Express for iSeries: List Price, $49
    Getting Started with WebSphere Express for iSeries: List Price, $49
    The All-Everything Operating System: List Price, $35
    The Best Joomla! Tutorial Ever!: List Price, $19.95

    Kronos Launches New InTouch Time Clock A Radical Idea For IBM i Software Pricing

    Leave a Reply Cancel reply

Volume 11, Number 34 -- November 9, 2011
THIS ISSUE SPONSORED BY:

WorksRight Software
ProData Computer Services
Twin Data Corporation

Table of Contents

  • Add Powerful Generic Processing to Your Applications
  • Meet JSON
  • Admin Alert: When You Can’t Answer Record Lock Errors

Content archive

  • The Four Hundred
  • Four Hundred Stuff
  • Four Hundred Guru

Recent Posts

  • Meet The Next Gen Of IBMers Helping To Build IBM i
  • Looks Like IBM Is Building A Linux-Like PASE For IBM i After All
  • Will Independent IBM i Clouds Survive PowerVS?
  • Now, IBM Is Jacking Up Hardware Maintenance Prices
  • IBM i PTF Guide, Volume 27, Number 24
  • Big Blue Raises IBM i License Transfer Fees, Other Prices
  • Keep The IBM i Youth Movement Going With More Training, Better Tools
  • Remain Begins Migrating DevOps Tools To VS Code
  • IBM Readies LTO-10 Tape Drives And Libraries
  • IBM i PTF Guide, Volume 27, Number 23

Subscribe

To get news from IT Jungle sent to your inbox every week, subscribe to our newsletter.

Pages

  • About Us
  • Contact
  • Contributors
  • Four Hundred Monitor
  • IBM i PTF Guide
  • Media Kit
  • Subscribe

Search

Copyright © 2025 IT Jungle