Skip to content

Commit

Permalink
Merge 01113ee into d08d1ef
Browse files Browse the repository at this point in the history
  • Loading branch information
Ram Krishna Banstola committed Nov 21, 2017
2 parents d08d1ef + 01113ee commit 22ee656
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/Skyscanner/JsonPath/JsonObject.php
Original file line number Diff line number Diff line change
Expand Up @@ -385,6 +385,17 @@ public function remove($jsonPath, $field)
}
return $this;
}

/**
* Sets value of smartGet property
*
* @param bool $smartGet
* @return void
*/
public function setSmartGet($smartGet)
{
$this->smartGet = $smartGet;
}

private function expressionValue(&$jsonObject, $expression)
{
Expand Down
15 changes: 15 additions & 0 deletions tests/Skyscanner/JsonPath/JsonObjectTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -956,4 +956,19 @@ public function testGetJsonObjects()

$this->assertFalse($jsonObject->getJsonObjects('$.abc'));
}

public function testSetSmartGet()
{
$jsonObject = new JsonObject($this->json);
$nodeValueArray = $jsonObject->get('$.store.bicycle.color');
$this->assertEquals(['red'],$nodeValueArray);

$jsonObject->setSmartGet(true);

$nodeValue = $jsonObject->get('$.store.bicycle.color');
$this->assertEquals('red',$nodeValue);

}


}

0 comments on commit 22ee656

Please sign in to comment.