Mantis - Quercus
|
|||||
Viewing Issue Advanced Details | |||||
|
|||||
ID: | Category: | Severity: | Reproducibility: | Date Submitted: | Last Update: |
3189 | minor | always | 12-17-08 23:45 | 12-18-08 09:35 | |
|
|||||
Reporter: | koreth | Platform: | |||
Assigned To: | nam | OS: | |||
Priority: | normal | OS Version: | |||
Status: | closed | Product Version: | 4.0.0 | ||
Product Build: | Resolution: | fixed | |||
Projection: | none | ||||
ETA: | none | Fixed in Version: | 4.0.0 | ||
|
|||||
Summary: | 0003189: json_decode fails on primitive values | ||||
Description: |
<?php print_r(json_decode('5')); Regular PHP prints "5". Quercus prints "Warning: error parsing '5': expected no more input [json_decode]". The following patch seems to match PHP's behavior (though it doesn't detect numeric values, which may or may not be worth doing): --- a/modules/quercus/src/com/caucho/quercus/lib/json/JsonDecoder.java +++ b/modules/quercus/src/com/caucho/quercus/lib/json/JsonDecoder.java @@ -51,6 +51,12 @@ class JsonDecoder { _isAssociative = assoc; + int c = skipWhitespace(); + if (c != '[' && c != '{' && c != '"') { + return s; + } + unread(); + Value val = jsonDecodeImpl(env); // Should now be at end of string or have only white spaces left. |
||||
Steps To Reproduce: | |||||
Additional Information: | |||||
Relationships | |||||
Attached Files: |
Notes | |||||
|
|||||
|
|