parseMetafieldValue
The parseMetafieldValue
function parses a Metafield's value
from a string into a sensible type corresponding to the Metafield's type
.
Example code
Anchor link to section titled "Example code"
Argument | Required |
---|---|
A Metafield object. | Yes |
Return type
Anchor link to section titled "Return type"Depending on the type
specified in the passed Metafield, the following type is returned:
Metafield type |
value type |
---|---|
date |
date |
date_time |
date |
boolean |
Boolean |
number_integer |
int |
number_decimal |
float |
json |
An object |
weight |
An object with value and unit keys |
dimension |
An object with value and unit keys |
volume |
An object with value and unit keys |
rating |
An object with scale_min , scale_max , and value keys |
color |
string |
single_line_text_field |
string |
multi_line_text_field |
string |
product_reference |
string |
file_reference |
string |
page_reference |
string |
variant_reference |
string |
url |
string |