如何在Python 3中将逻辑运算符查询字符串转换为字典

时间:2018-03-26 20:49:48

标签: json python-3.x mapping

我有查询字符串,我需要转换json对象,如下所示

((blue AND green) OR (brown AND green) OR green) AND NOT red

{
  "filter": {
"operator": "and",
"filters": [{
    "operator": "or",
    "filters": [{
        "operator": "and",
        "filters": [{
            "means": "contains",
            "value": "blue"
          },
          {
            "means": "contains",
            "value": "green"
          }
        ]
      },
      {
        "operator": "and",
        "filters": [{
            "means": "contains",
            "value": "brown"
          },
          {
            "means": "contains",
            "value": "green"
          }
        ]
      },
      {
        "means": "contains",
        "value": "green"
      }
    ]
  },
  {
    "means": "not contains",
    "value": "red"
  }
]
  }
}

你可以帮帮我吗?如何将查询转换为相同的字典,我需要良好的映射解决方案

0 个答案:

没有答案