'value'], '{"key-with-dash":\'value\'}' ], [ !$return_as_object, ['key-with-dash' => 'value'], '{"key-with-dash":\'value\'}' ], [ $return_as_object, ['key-with-quotes-\'"' => 'value'], '{"key-with-quotes-\\\'\\"":\'value\'}' ], [ !$return_as_object, ['key-with-quotes-\'"' => 'value'], '{"key-with-quotes-\\\'\\"":\'value\'}' ], [ $return_as_object, [-1 => ['agent_string', 'another_string']], '{"-1":{"0":\'agent_string\',"1":\'another_string\'}}' ], [ !$return_as_object, // JSON implementation will return slightly different result : // {"-1":[\'agent_string\',\'another_string\']} [-1 => ['agent_string', 'another_string']], '[[\'agent_string\',\'another_string\']]' ] ]; } /** * @dataProvider dataProvider * * @param bool $as_object * @param array|string|int|bool $source * @param string $expected */ public function testZbxJsvalue($as_object, $source, $expected) { $encoded = zbx_jsvalue($source, $as_object); $this->assertSame($expected, $encoded); } }