json - JSON_FORCE_OBJECT in lower version of PHP -


My PHP server does not accept the second parameter for json_encode (and I need JSON_FORCE_OBJECT). If the server does not support it then is there a way to get the same effect as JSON_FORCE_OBJECT? Do you know some custom functions similar to json_encode?

This should also work:

$ data = array ( 'Foo' = & gt; (object) 'array' ('bar' = & gt; 'foo');); Echo json_encode ($ data); // output {"foo": {"bar": "foo"}}

Comments