I want to read JSON data coming in to a server that has just enough PHP installed to run WordPress. I can create new .php files, but I don’t have the admin permissions to add any libraries that aren’t already there.
What’s the easiest way to grab & parse the JSON data out of an http request in this situation?
Thanks for the pointers, all, but the answer I was looking for was a much simpler one. The necessary two lines of code turned out to be:
Line one: Get the json data hitting the page.
Line two: Parse it into a proper hash.
If you are doing this within the context of WordPress, you should use the built-in HTTP helper functions (http://codex.wordpress.org/HTTP_API). They are simpler than curl. Example:
The above will return something like this:
Then you can use json_decode() to change the json into an array: http://www.php.net/manual/en/function.json-decode.php
With cURL and json_decode, you’d do it like this. If you’re running WordPress, chances are these are available.
Default WordPress function available Can you try this
Refer this https://developer.wordpress.org/reference/functions/wp_json_file_decode/