mherkender / actionjson Goto Github PK
View Code? Open in Web Editor NEWA faster, more advanced ActionScript 3 JSON library
Home Page: http://blog.brokenfunction.com/
A faster, more advanced ActionScript 3 JSON library
Home Page: http://blog.brokenfunction.com/
Hi,
In my test suite I'm seeing stack underflow errors while decoding JSON (synchronous version):
"VerifyError: Error #1024: Stack underflow occurred."
Has anyone else seen this? I'm trying to put together a test case that will allow others to attempt to reproduce..
I'm running into problems decoding a GeoJSON string that as far as I can tell is valid JSON.
Here's the full JSON string I'm sending to the decoder:
{"type":"FeatureCollection","crs":{"type":"name","properties":{"name":"urn:ogc:def:crs:EPSG::3857"}},"features":[{"type":"Feature","geometry":{"type":"Polygon","coordinates":[[[-13483771.9163,4699077.70459],[-13485123.1123,4700163.02188],[-13490514.2039,4696563.11539],[-13483771.9163,4699077.70459]]]},"properties":{"id":"057","name":"Nevada"}}]}
The problem comes in the "coordinates" field, which is a multidimensional array of points. When I decode the JSON, the coordinates field is returned as the following string:
-13483771.9163,4699077.70459,-13485123.1123,4700163.02188,-13490514.2039,4696563.11539,-13483771.9163,4699077.70459
Any ideas?
Thanks much!
Not sure if this is in your plan, but it would be nice if it could handle whitespace inside the json, ie:
{
"foo":"bar",
"baz":"boz"
}
There is an issue when decoding numbers in JsonDecoderAsync
: I noticed that when there is some numeric value which is not at the end of the object, it is not stored correctly in the result. I tried with some basic objects to confirm it:
In the following example, number_b is correct but number_a is undefined.
{"number_a":1,"number_b":2}
In this one, only number_c is correct. number_a and number_b are undefined
{"number_a":1,"number_b":2,"number_c":3}
Apparently, the problem is that, in case 0x100, you first store the value of the number in "result" but then you only put it in the stack when you find a "}" character. I followed the execution of the program and confirmed that later, you just overwrite result and the value of those numbers is never saved.
I added the line of code that saves the value of the number to the case when there is a comma (instead of a "}" character) and it is working perfectly now. Here is the code, the line I added is the second one:
if (char === 0x2c) {// == ,
_stack[_stack.length - 4][_stack[_stack.length - 3]] = result;
_stack.pop();
_stack[_stack.length - 1] = 0x304;
} else if (char === 0x7d) {// == }
_stack[_stack.length - 4][_stack[_stack.length - 3]] = result;
result = _stack[_stack.length - 4];
_stack.length -= 4;
} else {
throw new Error("Unexpected ] while parsing object");
}
Opening the swc I expected the 4 api, JsonDecoder, JsonEncoder, sonDecoderAsync, JsonEncoderAsync, but only found the Async pair. was this on purpose?
You permit NaN, Infinity and -Infinity to pass through while all other libraries (and I do mean all) filter these values to null.
Also, you parse -Infinity but throw an error on the other two values mentioned, you may want to implement better syntax filtering.
yeap, you missed xml type
if an object should not be serialized with for in loop, but in a special way
e.g. ObjectProxy from mx.utils. It does not seem currect code counts that case
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.