有没有可能转换一个字典的字符串表示形式,其中的键不是用双引号括起来的
'{output:{OUTPUT_PATH:hdfs://x.x.x.x:X/tmp/x/x,OUTPUT_TYPE:hdfs},''input:{INPUT_TEMPTABLE:sample,INPUT_TYPE:hdfs,INPUT_PATH:hdfs://x.x.x.x:X/sparkStream/sample1/},''process:{query.param:${http.query.param.name},PROCESS_SQL:1,PROCESS_TYPE:sql},''attributes:{path:./,restlistener.remote.source.host:127.0.0.1,filename:1211999192960535,restlistener.remote.user.dn:none,uuid:2b025f49-7d53-49db-8063-24ddda29fc4a}}'
像这样的字典:
{"output":{"OUTPUT_PATH":"hdfs://x.x.x.x:X/tmp/x/x","OUTPUT_TYPE":"hdfs"},"input":{"INPUT_TEMPTABLE":"sample","INPUT_TYPE":"hdfs","INPUT_PATH":"hdfs://x.x.x.x:X/sparkStream/sample1/"},"process":{"query.param":"${http.query.param.name}","PROCESS_SQL":"1","PROCESS_TYPE":"sql"},"attributes":{"path":"./","restlistener.remote.source.host":"127.0.0.1","filename":"1211999192960535","restlistener.remote.user.dn":"none","uuid":"2b025f49-7d53-49db-8063-24ddda29fc4a"}}
无法将数据pickle或转换为JSON之类的序列化格式,因为它来自当前格式的另一个进程。你知道吗
如果没有
re
,这可能更有效,并且有一些假设:'{
开头,以}'
结尾,''
分隔,数据中没有其他,''
,
分隔,数据中没有其他,
然后可以这样做:
输出是字典:
由于没有其他的输入字符串,这段代码没有进一步的测试,YMMV。你知道吗
相关问题 更多 >
编程相关推荐