Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Should parse json string flag #93

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion tap_shopify/streams/metafields.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@ def get_metafields(parent_object, since_id):
class Metafields(Stream):
name = 'metafields'
replication_object = shopify.Metafield
should_parse_json_string = None

def __init__(self, *args, **kwargs):
super(*args, **kwargs)
self.should_parse_json_string = Context.config.get('metafields_value_should_parse_json_string', True)

def get_objects(self):
# Get top-level shop metafields
Expand Down Expand Up @@ -58,7 +63,7 @@ def sync(self):
for metafield in self.get_objects():
metafield = metafield.to_dict()
value_type = metafield.get("value_type")
if value_type and value_type == "json_string":
if self.should_parse_json_string and value_type and value_type == "json_string":
value = metafield.get("value")
try:
metafield["value"] = json.loads(value) if value is not None else value
Expand Down