Skip to content

Commit

Permalink
add JSON_PRESERVE_ZERO_FRACTION for Json_encode (#481)
Browse files Browse the repository at this point in the history
* Update SmartSerializer.php

* add JSON_PRESERVE_ZERO_FRACTION for json_encode

* add JSON_PRESERVE_ZERO_FRACTION for json_encode

* add JSON_PRESERVE_ZERO_FRACTION for json_encode

* add JSON_PRESERVE_ZERO_FRACTION for json_encode

* require php version up to 5.6.6
  • Loading branch information
moknomo authored and polyfractal committed Oct 25, 2016
1 parent 9d376ba commit 2ab3971
Show file tree
Hide file tree
Showing 6 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion composer.json
Expand Up @@ -10,7 +10,7 @@
}
],
"require": {
"php": "^5.6|^7.0",
"php": "^5.6.6|^7.0",
"psr/log": "~1.0",
"guzzlehttp/ringphp" : "~1.0"
},
Expand Down
2 changes: 1 addition & 1 deletion src/Elasticsearch/Serializers/ArrayToJSONSerializer.php
Expand Up @@ -25,7 +25,7 @@ public function serialize($data)
if (is_string($data) === true) {
return $data;
} else {
$data = json_encode($data);
$data = json_encode($data, JSON_PRESERVE_ZERO_FRACTION);
if ($data === '[]') {
return '{}';
} else {
Expand Down
Expand Up @@ -22,7 +22,7 @@ class EverythingToJSONSerializer implements SerializerInterface
*/
public function serialize($data)
{
$data = json_encode($data);
$data = json_encode($data, JSON_PRESERVE_ZERO_FRACTION);
if ($data === '[]') {
return '{}';
} else {
Expand Down
2 changes: 1 addition & 1 deletion src/Elasticsearch/Serializers/SmartSerializer.php
Expand Up @@ -27,7 +27,7 @@ public function serialize($data)
if (is_string($data) === true) {
return $data;
} else {
$data = json_encode($data);
$data = json_encode($data, JSON_PRESERVE_ZERO_FRACTION);
if ($data === '[]') {
return '{}';
} else {
Expand Down
Expand Up @@ -24,7 +24,7 @@ public function testSerializeArray()

$ret = $serializer->serialize($body);

$body = json_encode($body);
$body = json_encode($body, JSON_PRESERVE_ZERO_FRACTION);
$this->assertEquals($body, $ret);
}

Expand Down
Expand Up @@ -24,7 +24,7 @@ public function testSerializeArray()

$ret = $serializer->serialize($body);

$body = json_encode($body);
$body = json_encode($body, JSON_PRESERVE_ZERO_FRACTION);
$this->assertEquals($body, $ret);
}

Expand Down

0 comments on commit 2ab3971

Please sign in to comment.