Brought up to date with the private repository (feea4c7)

This commit is contained in:
S committed 2026-10-14 20:57:33 +03:00
1 parent 1aa738d692
commit 1b1df1ae48
7925 files changed
+2617237 -20

No files matched your search

@@ -0,0 +1,125 @@
package com.adobe.serialization.json
{
public class JSONDecoder
{
private var value:*;
private var tokenizer:JSONTokenizer;
private var token:JSONToken;
public function JSONDecoder(s:String)
{
super();
this.tokenizer = new JSONTokenizer(s);
this.nextToken();
this.value = this.parseValue();
}
public function getValue() : *
{
return this.value;
}
private function nextToken() : JSONToken
{
return this.token = this.tokenizer.getNextToken();
}
private function parseArray() : Array
{
var a:Array = new Array();
this.nextToken();
if(this.token.type == JSONTokenType.RIGHT_BRACKET)
{
return a;
}
while(true)
{
a.push(this.parseValue());
this.nextToken();
if(this.token.type == JSONTokenType.RIGHT_BRACKET)
{
return a;
}
if(this.token.type == JSONTokenType.COMMA)
{
this.nextToken();
}
else
{
this.tokenizer.parseError("Expecting ] or , but found " + this.token.value);
}
}
return null;
}
private function parseObject() : Object
{
var key:String = null;
var o:Object = new Object();
this.nextToken();
if(this.token.type == JSONTokenType.RIGHT_BRACE)
{
return o;
}
while(true)
{
if(this.token.type == JSONTokenType.STRING)
{
key = String(this.token.value);
this.nextToken();
if(this.token.type == JSONTokenType.COLON)
{
this.nextToken();
o[key] = this.parseValue();
this.nextToken();
if(this.token.type == JSONTokenType.RIGHT_BRACE)
{
return o;
}
if(this.token.type == JSONTokenType.COMMA)
{
this.nextToken();
}
else
{
this.tokenizer.parseError("Expecting } or , but found " + this.token.value);
}
}
else
{
this.tokenizer.parseError("Expecting : but found " + this.token.value);
}
}
else
{
this.tokenizer.parseError("Expecting string but found " + this.token.value);
}
}
return null;
}
private function parseValue() : Object
{
switch(this.token.type)
{
case JSONTokenType.LEFT_BRACE:
return this.parseObject();
case JSONTokenType.LEFT_BRACKET:
return this.parseArray();
case JSONTokenType.STRING:
case JSONTokenType.NUMBER:
case JSONTokenType.TRUE:
case JSONTokenType.FALSE:
case JSONTokenType.NULL:
return this.token.value;
default:
this.tokenizer.parseError("Unexpected " + this.token.value);
return null;
}
}
}
}