Article
· Sep 26, 2023 1m read

Create JSON Objects and Arrays by SQL

The related package avoids adding %JSONAdaptor to each class but uses  instead   
SQL functions JSON_OBJECT() to create my JSON objects. With this approach, you can   
add JSON to any class - even deployed ones - without any need for change or recompiling.

The trigger was the Export of M:N relationships  as JSON  objects or arrays.

The typical structure of the export is  

{ M-element : {M-object},
   related-N-elements:
   [
     {N-element}, 
    {N-element},
    {N-element}
   ]
}

Demo data are an extract from Members in the Developer Community and
their Badges achieved in GlobalMasters. Real names are scrambled.

Examples:
From Member to its Badges

 

 

From Badge to Members

 

All Badges

 

Members with a minimum of badges

 

GitHub

Discussion (0)1
Log in or sign up to continue