HI i am trying to generate a jason paylod for an API which is querying the table in a database. The jason paolod structure is as follows.
{
"condition":"AND",
"rules": [
{
"condition": "AND",
"rules": [
{
"field": "column1",
"value": "4861868",
"operator": "equal"
}
]
}
]
}
Structure of Jason for multiple columns input
{
"condition":"AND",
"rules": [
{
"condition": "AND",
"rules": [
{
"field": "column1",
"value": "4861868",
"operator": "equal"
},
{
"field": "column2",
"value" : "2018-12-01"
"operator": "equal"
}
]
}
]
}
There are multiple columns in the table and the Jason should be generated for any arguments that are passed to the script. The script will take the values for those columns as input . What is the best possible way to store the inputs and can you please help me how can I generate a dynamic jason for this ?
Column1 | Column2 | column3 | column4 |
4861868 | HUIOIN | 2108-18-51 | NRIUNRI |
486849498 | VSMVOIRJ | 1956-12-05 | VMPEIORP |
85895995 | IPOPROER | 1965-12-16 | VNEIORV |
These columns are kind of optional to user. Only Column1 is a mandatory argument to the script. Please kindly help me how can i generate Jason for this kind of condition
@JoshuaBixby . Can you please help
I usually construct the payload as a python dict then convert the dict to json using the technique described here.