[wp-trac] [WordPress Trac] #42094: REST API: extend _fields parameter to selectively include nested fields in response JSON

WordPress Trac noreply at wordpress.org
Thu Jan 24 19:55:07 UTC 2019


#42094: REST API: extend _fields parameter to selectively include nested fields in
response JSON
-------------------------+-------------------------
 Reporter:  kadamwhite   |       Owner:  kadamwhite
     Type:  enhancement  |      Status:  assigned
 Priority:  normal       |   Milestone:  5.2
Component:  REST API     |     Version:  4.9
 Severity:  normal       |  Resolution:
 Keywords:  needs-patch  |     Focuses:
-------------------------+-------------------------

Comment (by danielbachhuber):

 I'm amenable to dot syntax too (i.e. `?_fields=content.raw`). My original
 suggestion for `?_fields=content[raw]` was to follow PHP's existing
 pattern for transforming `?bar[]=1&bar[]=2&bar[]=3` into `$_GET['bar'] =
 array(1, 2, 3)`.

 We could support both if it's not too difficult. Otherwise, I'm fine with
 dot syntax if that's what everyone else prefers.

 One minor backwards compatibility concern: a field could theoretically be
 named `'content.raw'`. In this scenario, `?_fields=content.raw` should
 return the `'content.raw'` field, not a `'content'` field with sub-field
 `'raw'`.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/42094#comment:6>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list