Skip to content

Commit 2ab3971

Browse files
moknomopolyfractal
authored andcommitted
add JSON_PRESERVE_ZERO_FRACTION for Json_encode (#481)
* 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
1 parent 9d376ba commit 2ab3971

File tree

6 files changed

+6
-6
lines changed

6 files changed

+6
-6
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
}
1111
],
1212
"require": {
13-
"php": "^5.6|^7.0",
13+
"php": "^5.6.6|^7.0",
1414
"psr/log": "~1.0",
1515
"guzzlehttp/ringphp" : "~1.0"
1616
},

src/Elasticsearch/Serializers/ArrayToJSONSerializer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public function serialize($data)
2525
if (is_string($data) === true) {
2626
return $data;
2727
} else {
28-
$data = json_encode($data);
28+
$data = json_encode($data, JSON_PRESERVE_ZERO_FRACTION);
2929
if ($data === '[]') {
3030
return '{}';
3131
} else {

src/Elasticsearch/Serializers/EverythingToJSONSerializer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class EverythingToJSONSerializer implements SerializerInterface
2222
*/
2323
public function serialize($data)
2424
{
25-
$data = json_encode($data);
25+
$data = json_encode($data, JSON_PRESERVE_ZERO_FRACTION);
2626
if ($data === '[]') {
2727
return '{}';
2828
} else {

src/Elasticsearch/Serializers/SmartSerializer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public function serialize($data)
2727
if (is_string($data) === true) {
2828
return $data;
2929
} else {
30-
$data = json_encode($data);
30+
$data = json_encode($data, JSON_PRESERVE_ZERO_FRACTION);
3131
if ($data === '[]') {
3232
return '{}';
3333
} else {

tests/Elasticsearch/Tests/Serializers/ArrayToJSONSerializerTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public function testSerializeArray()
2424

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

27-
$body = json_encode($body);
27+
$body = json_encode($body, JSON_PRESERVE_ZERO_FRACTION);
2828
$this->assertEquals($body, $ret);
2929
}
3030

tests/Elasticsearch/Tests/Serializers/EverythingToJSONSerializerTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public function testSerializeArray()
2424

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

27-
$body = json_encode($body);
27+
$body = json_encode($body, JSON_PRESERVE_ZERO_FRACTION);
2828
$this->assertEquals($body, $ret);
2929
}
3030

0 commit comments

Comments
 (0)