fix JSON handling
Project: http://git-wip-us.apache.org/repos/asf/flex-asjs/repo Commit: http://git-wip-us.apache.org/repos/asf/flex-asjs/commit/d850c918 Tree: http://git-wip-us.apache.org/repos/asf/flex-asjs/tree/d850c918 Diff: http://git-wip-us.apache.org/repos/asf/flex-asjs/diff/d850c918 Branch: refs/heads/develop Commit: d850c918dd3633bcb64395ce0f5dd620a9312e50 Parents: efa544f Author: Alex Harui <[email protected]> Authored: Fri Oct 10 11:17:09 2014 -0700 Committer: Alex Harui <[email protected]> Committed: Fri Oct 17 22:38:41 2014 -0700 ---------------------------------------------------------------------- .../FlexJSUI/src/org/apache/flex/net/JSONInputParser.as | 6 ++++++ .../FlexJSUI/src/org/apache/flex/net/JSONItemConverter.as | 5 +++++ 2 files changed, 11 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/d850c918/frameworks/as/projects/FlexJSUI/src/org/apache/flex/net/JSONInputParser.as ---------------------------------------------------------------------- diff --git a/frameworks/as/projects/FlexJSUI/src/org/apache/flex/net/JSONInputParser.as b/frameworks/as/projects/FlexJSUI/src/org/apache/flex/net/JSONInputParser.as index 9cbf24f..08eecc5 100644 --- a/frameworks/as/projects/FlexJSUI/src/org/apache/flex/net/JSONInputParser.as +++ b/frameworks/as/projects/FlexJSUI/src/org/apache/flex/net/JSONInputParser.as @@ -42,6 +42,12 @@ package org.apache.flex.net */ public function parseItems(s:String):Array { + var c:int = s.indexOf("["); + if (c != -1) + { + var c2:int = s.lastIndexOf("]"); + s = s.substring(c + 1, c2); + } return s.split("},"); } } http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/d850c918/frameworks/as/projects/FlexJSUI/src/org/apache/flex/net/JSONItemConverter.as ---------------------------------------------------------------------- diff --git a/frameworks/as/projects/FlexJSUI/src/org/apache/flex/net/JSONItemConverter.as b/frameworks/as/projects/FlexJSUI/src/org/apache/flex/net/JSONItemConverter.as index e295039..d8e1251 100644 --- a/frameworks/as/projects/FlexJSUI/src/org/apache/flex/net/JSONItemConverter.as +++ b/frameworks/as/projects/FlexJSUI/src/org/apache/flex/net/JSONItemConverter.as @@ -34,6 +34,11 @@ package org.apache.flex.net { public function convertItem(data:String):Object { + var c:int = data.indexOf("{"); + if (c > 0) + data = data.substring(c); + if (data.indexOf("}") == -1) + data += "}"; return JSON.parse(data); } }
