Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F104171756
PhutilJSONParser.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Thu, Mar 6, 23:43
Size
1 KB
Mime Type
text/x-php
Expires
Sat, Mar 8, 23:43 (2 d)
Engine
blob
Format
Raw Data
Handle
24757500
Attached To
rPHU libphutil
PhutilJSONParser.php
View Options
<?php
/**
* WARNING: This is not quite usable yet. See T5297.
*
* @phutil-external-symbol class JsonLintJsonParser
* @phutil-external-symbol class JsonLintParsingException
*/
final
class
PhutilJSONParser
{
public
function
parse
(
$json
)
{
$jsonlint_root
=
phutil_get_library_root
(
'phutil'
).
'/../externals/jsonlint'
;
require_once
(
$jsonlint_root
.
'/src/Seld/JsonLint/JsonParser.php'
);
require_once
(
$jsonlint_root
.
'/src/Seld/JsonLint/Lexer.php'
);
require_once
(
$jsonlint_root
.
'/src/Seld/JsonLint/ParsingException.php'
);
require_once
(
$jsonlint_root
.
'/src/Seld/JsonLint/Undefined.php'
);
$parser
=
new
JsonLintJsonParser
();
try
{
$output
=
$parser
->
parse
(
$json
);
}
catch
(
JsonLintParsingException
$ex
)
{
throw
new
PhutilJSONParserException
(
$ex
->
getMessage
());
}
if
(!
is_array
(
$output
))
{
throw
new
PhutilJSONParserException
(
pht
(
'%s is not a valid JSON object.'
,
PhutilReadableSerializer
::
printShort
(
$json
)));
}
return
$output
;
}
}
Event Timeline
Log In to Comment