Page MenuHomePhabricator

D9623.id23081.diff
No OneTemporary

D9623.id23081.diff

diff --git a/externals/jsonlint/src/Seld/JsonLint/JsonParser.php b/externals/jsonlint/src/Seld/JsonLint/JsonParser.php
--- a/externals/jsonlint/src/Seld/JsonLint/JsonParser.php
+++ b/externals/jsonlint/src/Seld/JsonLint/JsonParser.php
@@ -358,7 +358,7 @@
case 6:
return $yyval->token = $tokens[$len-1];
case 13:
- $yyval->token = new stdClass;
+ $yyval->token = array();
break;
case 14:
$yyval->token = $tokens[$len-1];
@@ -367,9 +367,9 @@
$yyval->token = array($tokens[$len-2], $tokens[$len]);
break;
case 16:
- $yyval->token = new stdClass;
+ $yyval->token = array();
$property = $tokens[$len][0] === '' ? '_empty_' : $tokens[$len][0];
- $yyval->token->$property = $tokens[$len][1];
+ $yyval->token[$property] = $tokens[$len][1];
break;
case 17:
$yyval->token = $tokens[$len-2];
diff --git a/src/parser/PhutilJSONParser.php b/src/parser/PhutilJSONParser.php
--- a/src/parser/PhutilJSONParser.php
+++ b/src/parser/PhutilJSONParser.php
@@ -21,16 +21,10 @@
$parser = new JsonLintJsonParser();
try {
- $output = $parser->parse($json);
+ return $parser->parse($json);
} catch (JsonLintParsingException $ex) {
throw new PhutilJSONParserException($ex->getMessage());
}
-
- if ($output instanceof stdClass) {
- return (array)$output;
- }
-
- return $output;
}
}
diff --git a/src/parser/__tests__/PhutilJSONParserTestCase.php b/src/parser/__tests__/PhutilJSONParserTestCase.php
--- a/src/parser/__tests__/PhutilJSONParserTestCase.php
+++ b/src/parser/__tests__/PhutilJSONParserTestCase.php
@@ -14,6 +14,7 @@
'{}' => array(),
'{"foo": "bar"}' => array('foo' => 'bar'),
'[1, "foo", true, null]' => array(1, 'foo', true, null),
+ '{"foo": {"bar": "baz"}}' => array('foo' => array('bar' => 'baz')),
);
foreach ($tests as $input => $expect) {

File Metadata

Mime Type
text/plain
Expires
Sat, Apr 12, 7:50 AM (1 w, 4 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7705627
Default Alt Text
D9623.id23081.diff (1 KB)

Event Timeline