Whenever I am asked for an example of how to generate a JSON array or how to consume JSON data I have to point people to different posts, rather than have one that covers both. I have written this post to be that, examples of how to create and how to consume JSON.
I will be using Db2 for i to generate JSON, as I find it simpler to use than doing the equivalent in RPG.
I am going to give four examples in this post to show how to generate a simple JSON array, one with labels and the other without. Then consume the generated JSON into a format that can be easily processed by RPG. All of these examples are going to use embedded SQL in RPG programs.
I will be using my PERSON DDL Table for the input for these examples. What I want to do is to create a JSON containing:



