Object 这个对象符号格式是什么?

Object 这个对象符号格式是什么?,object,format,notation,Object,Format,Notation,我正在处理程序中的数据,我遇到了这种数据格式,但我不知道如何解析它 response="0",num=3,list=[ {type="url1",url="http://www.xxx1.com"}, {type="url2",url="http://www.xxx2.com"}, {type="url3",url="http://www.xxx3.com"} ],type="LIST", id=1 有人有什么建议吗 谢谢 我不知道这种格式是什么,但它非常接近JSON 您只需将key=替换为“

我正在处理程序中的数据,我遇到了这种数据格式,但我不知道如何解析它

response="0",num=3,list=[
{type="url1",url="http://www.xxx1.com"},
{type="url2",url="http://www.xxx2.com"},
{type="url3",url="http://www.xxx3.com"}
],type="LIST", id=1
有人有什么建议吗


谢谢

我不知道这种格式是什么,但它非常接近JSON

您只需将
key=
替换为
“key”:
并将额外的大括号括起来,使其成为有效的JSON,这样您就可以使用任何JSON库来解析它

response="0",num=3,list=[
{type="url1",url="http://www.xxx1.com"},
{type="url2",url="http://www.xxx2.com"},
{type="url3",url="http://www.xxx3.com"}
],type="LIST", id=1
您可以使用以下Perl代码对其进行解析:

use JSON::XS;

my $input = qq{
    response="0",num=3,list=[
    {type="url1",url="http://www.xxx1.com"},
    {type="url2",url="http://www.xxx2.com"},
    {type="url3",url="http://www.xxx3.com"}
    ],type="LIST", id=1
};
my $str = "{" . $input . "}";
$str =~ s/(\w+)=/"$1":/g; # replace key= with "key": (fragile!)
my $json = decode_json($str);
# at this point, $json is object containing all fields you need.
# ...
python:

import json
import re
str = """response="0",num=3,list=[
{type="url1",url="http://www.xxx1.com"},
{type="url2",url="http://www.xxx2.com"},
{type="url3",url="http://www.xxx3.com"}
],type="LIST", id=1"""
fn = lambda m: '"' + m.group(1) + '":'
json_str = "{"+re.sub(r'(\w+)=', fn, str)+"}"
print json_str
print "==========================="
dict_obj = json.loads(json_str)
print dict_obj