Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F15481992
D9623.id23083.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
2 KB
Referenced Files
None
Subscribers
None
D9623.id23083.diff
View Options
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];
@@ -386,7 +386,7 @@
} while (isset($tokens[$len-2]->$duplicateKey));
$key = $duplicateKey;
}
- $tokens[$len-2]->$key = $tokens[$len][1];
+ $tokens[$len-2][$key] = $tokens[$len][1];
break;
case 18:
$yyval->token = array();
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
Details
Attached
Mime Type
text/plain
Expires
Thu, Apr 10, 1:35 AM (2 w, 11 h ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7738548
Default Alt Text
D9623.id23083.diff (2 KB)
Attached To
Mode
D9623: Modify the JsonLint library to return `array` instead of `stdClass`.
Attached
Detach File
Event Timeline
Log In to Comment