According to the WP-CLI 1.5.0 Announcement:
The --meta_input option of the post create and post update commands now accepts JSON-formatted arrays, so you can add or update your post and its meta in one go:
$ wp post create --post_title='Title' --post_content='Content.' --meta_input='{"key1":"value1","key2":"value2"}
Success: Created post 123.
Unfortunately, there doesn't seem to be an equivalent export option for post meta list or post meta get.
wp post meta list 123 --fields=meta_key,meta_value --format=json will create [{"meta_key":"foo", "meta_value":"bar}] and not {"foo":"bar"} as shown in the examples for post update and post create.
post meta list
[--format=<format>]
Accepted values: table, csv, json, count. Default: table
post meta get
[--format=<format>]
Accepted values: table, json. Default: table
[--format=<format>]
Render output in a particular format.
---
default: table
options:
– table
– csv
– ids
– json
– count
– yaml
A suggestion has been made to add a new --format=meta_input or similar.
While the argument meta_input makes sense to solve this particular issue (based on import) it doesn't really describe the export type which is <key>:<value> JSON.
--format=meta_input
--format=json-key-value
--format=json-key:value
--format=jsonkv
--format=json-kv
According to the WP-CLI 1.5.0 Announcement:
Unfortunately, there doesn't seem to be an equivalent export option for
post meta listorpost meta get.wp post meta list 123 --fields=meta_key,meta_value --format=jsonwill create[{"meta_key":"foo", "meta_value":"bar}]and not{"foo":"bar"}as shown in the examples forpost updateandpost create.post meta listpost meta getA suggestion has been made to add a new
--format=meta_inputor similar.While the argument
meta_inputmakes sense to solve this particular issue (based on import) it doesn't really describe the export type which is<key>:<value>JSON.--format=meta_input--format=json-key-value--format=json-key:value--format=jsonkv--format=json-kv