IBM / db2sock-ibmi

An asynchronous PASE Db2 and IBM i integration library
MIT License
4 stars 7 forks source link

Calling multiple actions of the same type #35

Closed kadler closed 3 years ago

kadler commented 6 years ago

Original report by me.


Due to the format of the JSON that db2sock uses, it seems that there is no way to execute multiple actions of the same type in the same request. The problem is that it uses the key in the parent object to define the action to be performed, but JSON keys must be unique. If you can only have one pgm or cmd key, how would you be able to call mulitple programs or commands in the same invocation.

eg.

{
    "pgm": [{
            "name": "HELLO",
            "lib": "DB2JSON"
        },
        {
            "s": {
                "name": "char",
                "type": "128a",
                "value": "Hi there"
            }
        }
    ],
    "pgm": [{                                    <--- this is invalid JSON
            "name": "HELLO",
            "lib": "DB2JSON"
        },
        {
            "s": {
                "name": "char",
                "type": "128a",
                "value": "Hi there"
            }
        }
    ]
}
kadler commented 6 years ago

Original comment by Aaron Bartell (Bitbucket: aaronbartell, GitHub: aaronbartell).


I propose changing the top level to an array of objects, each with an action key,

I agree.

kadler commented 6 years ago

I propose changing the top level to an array of objects, each with an action key, with the previous key name as its value. eg.


[{
        "action": "pgm"
        ...
    },
    {
        "action": "pgm"
        ...
    }

]