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

added json check stacks #178

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

added json check stacks #178

wants to merge 1 commit into from

Conversation

kurtbrose
Copy link
Collaborator

for comparison, here's what json.dumps() does the the two error stacks added:

>>> json.dumps({'a': [{'b': {1: 2}}]})
'{"a": [{"b": {"1": 2}}]}'
>>> json.dumps({'a': [{'b': 1j}]})
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Program Files\Python37\Lib\json\__init__.py", line 231, in dumps
    return _default_encoder.encode(obj)
  File "C:\Program Files\Python37\Lib\json\encoder.py", line 199, in encode
    chunks = self.iterencode(o, _one_shot=True)
  File "C:\Program Files\Python37\Lib\json\encoder.py", line 257, in iterencode
    return _iterencode(o, 0)
  File "C:\Program Files\Python37\Lib\json\encoder.py", line 179, in default
    raise TypeError(f'Object of type {o.__class__.__name__} '
TypeError: Object of type complex is not JSON serializable

Copy link
Owner

@mahmoud mahmoud left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting stress testing. Lil bit worried about maintenance, but this is as good a guess of what advanced matching specs might look like post rollout.

- Spec: Match(Switch([(dict, {str: Ref('json')}), (list, [Ref('json')]), (...
+ Spec: Switch([(dict, {str: Ref('json')}), (list, [Ref('json')]), (Or(str...
|\\ Spec: dict
|X glom.matching.Typeglom.matching.MatchError: expected type dict, not list
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm what's goin on with this line?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants