Opened 6 months ago

Closed 6 months ago

Last modified 6 months ago

#22531 closed enhancement (wontfix)

integrate fetch_json($url)

Reported by: alexvorn2 Owned by:
Priority: normal Milestone:
Component: General Version:
Severity: normal Keywords:
Cc:

Description

as we have fetch_feed() function, it will be great to have fetch_json() function too, to download a json file and decode into an array.

Change History (4)

comment:1 follow-up: ↓ 3   nacin6 months ago

Feeds need to be parsed. JSON doesn't. Here's your function: json_decode( file_get_contents( $url ) );

  • Milestone Awaiting Review deleted
  • Resolution set to wontfix
  • Status changed from new to closed
  • Type changed from defect (bug) to enhancement

There is no need of it.

comment:3 in reply to: ↑ 1   alexvorn26 months ago

Replying to nacin:

Feeds need to be parsed. JSON doesn't. Here's your function: json_decode( file_get_contents( $url ) );

It is not nice to have file_get_contents function in a theme

You're right. This would be the proper way to do it in WordPress:

json_decode( wp_remote_retrieve_body( wp_remote_get( $url ) ) );

Note: See TracTickets for help on using tickets.