Skip to content
This repository was archived by the owner on Apr 20, 2021. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions src/Json/Json.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,13 @@ public function read($expression, PropertyAccessor $accessor)

public function encode($pretty = true)
{
$flags = JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE;

if (true === $pretty && defined('JSON_PRETTY_PRINT')) {
// Cannot test this part JSON_PRETTY_PRINT is only 5.4
return json_encode($this->content, JSON_PRETTY_PRINT);
$flags |= JSON_PRETTY_PRINT;
}

return json_encode($this->content);
return json_encode($this->content, $flags);
}

public function __toString()
Expand Down
10 changes: 5 additions & 5 deletions tests/features/fr/json.feature
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ Fonctionnalité:
Et le nœud JSON "foo" devrait contenir "bar"
Et le nœud JSON "foo" ne devrait pas contenir "something else"

Et le nœud JSON "numbers[0]" devrait contenir "one"
Et le nœud JSON "numbers[0]" devrait contenir "öne"
Et le nœud JSON "numbers[1]" devrait contenir "two"
Et le nœud JSON "numbers[2]" devrait contenir "three"
Et le nœud JSON "numbers[3].complexeshizzle" devrait être égal à "true"
Expand All @@ -32,13 +32,13 @@ Fonctionnalité:

Et les nœuds JSON devraient être égaux à:
| foo | bar |
| numbers[0] | one |
| numbers[0] | öne |
| numbers[1] | two |
| numbers[2] | three |

Et les nœuds JSON devraient contenir:
| foo | bar |
| numbers[0] | one |
| numbers[0] | öne |
| numbers[1] | two |
| numbers[2] | three |

Expand Down Expand Up @@ -71,7 +71,7 @@ Fonctionnalité:
"numbers": {
"type": "array",
"required":true,
"one": {
"öne": {
"type": "string",
"required":true
},
Expand All @@ -95,7 +95,7 @@ Fonctionnalité:
{
"foo": "bar",
"numbers": [
"one",
"öne",
"two",
"three",
{
Expand Down
6 changes: 3 additions & 3 deletions tests/features/ja/json.feature
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
かつ JSONのノード"foo"が"bar"を含むこと
かつ JSONのノード"foo"が"something else"を含まないこと

かつ JSONのノード"numbers[0]"が"one"を含むこと
かつ JSONのノード"numbers[0]"が"öne"を含むこと
かつ JSONのノード"numbers[1]"が"two"を含むこと
かつ JSONのノード"numbers[2]"が"three"を含むこと
かつ JSONのノード"numbers[3].complexeshizzle"が"true"と等しいこと
Expand Down Expand Up @@ -60,7 +60,7 @@
"numbers": {
"type": "array",
"required":true,
"one": {
"öne": {
"type": "string",
"required":true
},
Expand All @@ -85,7 +85,7 @@
{
"foo": "bar",
"numbers": [
"one",
"öne",
"two",
"three",
{
Expand Down
10 changes: 5 additions & 5 deletions tests/features/json.feature
Original file line number Diff line number Diff line change
Expand Up @@ -22,25 +22,25 @@ Feature: Testing JSONContext
And the JSON node "foo" should contain "bar"
And the JSON node "foo" should not contain "something else"

And the JSON node "numbers[0]" should contain "one"
And the JSON node "numbers[0]" should contain "öne"
And the JSON node "numbers[1]" should contain "two"
And the JSON node "numbers[2]" should contain "three"
And the JSON node "numbers[3].complexeshizzle" should be equal to "true"
And the JSON node "numbers[3].so[0]" should be equal to "very"
And the JSON node "numbers[3].so[1].complicated" should be equal to "indeed"
And the JSON node "numbers[0]" should match "/o.{1}e/"
And the JSON node "numbers[0]" should match "/ö.{1}e/"
And the JSON node "numbers[1]" should match "/.{2}o/"
And the JSON node "numbers[2]" should match "/[a-z]{3}e.+/"

And the JSON nodes should be equal to:
| foo | bar |
| numbers[0] | one |
| numbers[0] | öne |
| numbers[1] | two |
| numbers[2] | three |

And the JSON nodes should contain:
| foo | bar |
| numbers[0] | one |
| numbers[0] | öne |
| numbers[1] | two |
| numbers[2] | three |

Expand Down Expand Up @@ -138,7 +138,7 @@ Feature: Testing JSONContext
{
"foo": "bar",
"numbers": [
"one",
"öne",
"two",
"three",
{
Expand Down
10 changes: 5 additions & 5 deletions tests/features/pt/json.feature
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ Funcionalidade: Testando o JSONContext
E o nó JSON "foo" deve conter "bar"
E o nó JSON "foo" não deve conter "something else"

E o nó JSON "numbers[0]" deve conter "one"
E o nó JSON "numbers[0]" deve conter "öne"
E o nó JSON "numbers[1]" deve conter "two"
E o nó JSON "numbers[2]" deve conter "three"
E o nó JSON "numbers[3].complexeshizzle" deve ser igual a "true"
Expand All @@ -32,13 +32,13 @@ Funcionalidade: Testando o JSONContext

E os nós JSON devem ser iguais a:
| foo | bar |
| numbers[0] | one |
| numbers[0] | öne |
| numbers[1] | two |
| numbers[2] | three |

E os nós JSON devem conter:
| foo | bar |
| numbers[0] | one |
| numbers[0] | öne |
| numbers[1] | two |
| numbers[2] | three |

Expand Down Expand Up @@ -75,7 +75,7 @@ Funcionalidade: Testando o JSONContext
"numbers": {
"type": "array",
"required":true,
"one": {
"öne": {
"type": "string",
"required":true
},
Expand All @@ -99,7 +99,7 @@ Funcionalidade: Testando o JSONContext
{
"foo": "bar",
"numbers": [
"one",
"öne",
"two",
"three",
{
Expand Down
12 changes: 6 additions & 6 deletions tests/features/ru/json.feature
Original file line number Diff line number Diff line change
Expand Up @@ -23,25 +23,25 @@
И узел JSON "foo" должен содержать "bar"
И узел JSON "foo" не должен содержать "something else"

И узел JSON "numbers[0]" должен содержать "one"
И узел JSON "numbers[0]" должен содержать "öne"
И узел JSON "numbers[1]" должен содержать "two"
И узел JSON "numbers[2]" должен содержать "three"
И узел JSON "numbers[3].complexeshizzle" должен быть равен "true"
И узел JSON "numbers[3].so[0]" должен быть равен "very"
И узел JSON "numbers[3].so[1].complicated" должен быть равен "indeed"
И узел JSON "numbers[0]" должен соответствовать "/o.{1}e/"
И узел JSON "numbers[0]" должен соответствовать "/ö.{1}e/"
И узел JSON "numbers[1]" должен соответствовать "/.{2}o/"
И узел JSON "numbers[2]" должен соответствовать "/[a-z]{3}e.+/"

И узлы JSON должны быть равны:
| foo | bar |
| numbers[0] | one |
| numbers[0] | öne |
| numbers[1] | two |
| numbers[2] | three |

И узлы JSON должны содержать:
| foo | bar |
| numbers[0] | one |
| numbers[0] | öne |
| numbers[1] | two |
| numbers[2] | three |

Expand Down Expand Up @@ -78,7 +78,7 @@
"numbers": {
"type": "array",
"required":true,
"one": {
"öne": {
"type": "string",
"required":true
},
Expand Down Expand Up @@ -139,7 +139,7 @@
{
"foo": "bar",
"numbers": [
"one",
"öne",
"two",
"three",
{
Expand Down
4 changes: 2 additions & 2 deletions tests/fixtures/www/json/imajson.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
{
"foo": "bar",
"numbers": [
"one",
"öne",
"two",
"three",
{
"complexeshizzle": true,
"so": ["very", {"complicated": "indeed"}]
}
]
}
}