I get this data as an ajax response:
{
"idArray" = (
"99516",
"99518",
"97344",
"97345",
"98425"
);
"frame" = {
"size" = {
"width" = "8";
"height" = "8";
};
"origin" = {
"x" = "244";
"y" = "345";
};
};
},
This is just a portion of the Data, but it continues in the same format. I don't have access to the source of the files that generate this data.
Is this a known format or something custom?
Since people tend to throw regular expressions at everything, even things that can not be parsed with regular expressions (ie. non-regular languages): I've written a proof-of-concept parser for this data format:
The output is:
Notes
the original input has a trailing
,
. I've removed that character. It will throw an error (more input) if you put it back.This parser is naive in the sense that it tokenizes all input before it starts parsing. This is not good for large input.
I've not added escape detection for strings in the tokenizer. Like:
"foo\"bar"
.This was a fun exercise. If you have any questions let me know.
Edit: I see this is a JavaScript question. Porting the PHP to JavaScript shouldn't be too hard. The
list($foo, $bar) = func()
is equivalent to:var res = func(); var foo = res[0]; var bar = res[1];