From b1431d427a0b837f567a32b8e4161fd465416b3a Mon Sep 17 00:00:00 2001 From: ccccly Date: Fri, 10 Aug 2018 23:10:24 +0800 Subject: [PATCH] Support nested json path --- JsonHelper.php | 22 ++++++++++++++++++++++ README.md | 24 ++++++++++++++++++++++++ SpecialOAuth2Client.php | 5 +++-- tests/phpunit/JsonHelperTest.php | 31 +++++++++++++++++++++++++++++++ 4 files changed, 80 insertions(+), 2 deletions(-) create mode 100644 JsonHelper.php create mode 100644 tests/phpunit/JsonHelperTest.php diff --git a/JsonHelper.php b/JsonHelper.php new file mode 100644 index 0000000..354d085 --- /dev/null +++ b/JsonHelper.php @@ -0,0 +1,22 @@ + array( + "username" => "username", + "email" => "localhost@email.com" + ) + ); + self::assertEquals("localhost@email.com", JsonHelper::extractValue($json_array, "user.email")); + self::assertEquals("username", JsonHelper::extractValue($json_array, "user.username")); + self::assertEquals("username", JsonHelper::extractValue($json_array, "user")["username"]); + self::assertNull(JsonHelper::extractValue($json_array, "user.emails")); + self::assertNull(JsonHelper::extractValue($json_array, "$.user.email")); + } + + protected function tearDown() + { + parent::tearDown(); + } +}