将表示列表的字符串转换为Jython中的实际列表?

问题描述 投票:1回答:1

我在Jython中有一个字符串,它表示JSON数组的列表:

[{"datetime": 1570216445000, "type": "test"},{"datetime": 1570216455000, "type": "test2"}]

但是,如果我尝试对此进行迭代,它将仅对每个字符进行迭代。如何使它遍历实际列表,以便可以取出每个JSON数组?

背景信息-该脚本正在Apache NiFi中运行,下面是字符串源自的代码:

from org.apache.commons.io import IOUtils
...    
def process(self, inputStream):
        text = IOUtils.toString(inputStream,StandardCharsets.UTF_8)
type-conversion apache-nifi jython
1个回答
2
投票

您可以解析JSON,类似于在Python中的操作。

© www.soinside.com 2019 - 2024. All rights reserved.