aboutsummaryrefslogtreecommitdiff
path: root/php/src/Google/Protobuf
diff options
context:
space:
mode:
Diffstat (limited to 'php/src/Google/Protobuf')
-rw-r--r--php/src/Google/Protobuf/Internal/GPBUtil.php4
-rw-r--r--php/src/Google/Protobuf/Internal/Message.php12
2 files changed, 12 insertions, 4 deletions
diff --git a/php/src/Google/Protobuf/Internal/GPBUtil.php b/php/src/Google/Protobuf/Internal/GPBUtil.php
index ec0bf6bd..7b5cc7d1 100644
--- a/php/src/Google/Protobuf/Internal/GPBUtil.php
+++ b/php/src/Google/Protobuf/Internal/GPBUtil.php
@@ -438,8 +438,8 @@ class GPBUtil
$nanoseconds = intval($nanoseconds);
// remove the nanoseconds and preceding period from the timestamp
- $date = substr($timestamp, 0, $periodIndex - 1);
- $timezone = substr($timestamp, $periodIndex + $nanosecondsLength);
+ $date = substr($timestamp, 0, $periodIndex);
+ $timezone = substr($timestamp, $periodIndex + $nanosecondsLength + 1);
$timestamp = $date.$timezone;
}
}
diff --git a/php/src/Google/Protobuf/Internal/Message.php b/php/src/Google/Protobuf/Internal/Message.php
index 8ff141ca..147aaab8 100644
--- a/php/src/Google/Protobuf/Internal/Message.php
+++ b/php/src/Google/Protobuf/Internal/Message.php
@@ -1157,9 +1157,17 @@ class Message
public function parseFromJsonStream($input)
{
$array = json_decode($input->getData(), true, 512, JSON_BIGINT_AS_STRING);
+ if ($this instanceof \Google\Protobuf\ListValue) {
+ $array = ["values"=>$array];
+ }
if (is_null($array)) {
- throw new GPBDecodeException(
- "Cannot decode json string.");
+ if ($this instanceof \Google\Protobuf\Value) {
+ $this->setNullValue(\Google\Protobuf\NullValue::NULL_VALUE);
+ return;
+ } else {
+ throw new GPBDecodeException(
+ "Cannot decode json string: " . $input->getData());
+ }
}
try {
$this->mergeFromJsonArray($array);