ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

Concat Json

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Concat Json

    Hi all,

    I have a table with 2 fields:

    key
    DataInJSon

    something like:
    CARNIVORES A json with a list of carnivores animal and some details
    VEGETARIAN
    A json with a list of vegetarian animal and some details
    OMNIVORES A json with a list of vegetarian animal and some details






    Now what I want is a json like this:

    Code:
    {"Animal" : [key1: datainJson1, key2: datainJson2, key3 : datainJson3]}
    How can I concatenate all my rows table to generate a json with all my rows?

    Many thanks.

  • #2
    Hi,

    more simply than I think:

    Code:
    Select Json_Object(
    'listAllAnimal' Value Json_Arrayagg(
    datainjson Format Json
    )
    )
    From Animaltable

    Comment

    Working...
    X