mirror of
https://github.com/graphql-python/graphene.git
synced 2025-02-02 12:44:15 +03:00
Added JSONString
This commit is contained in:
parent
f2ed1e58d9
commit
043e548f49
23
graphene/types/json.py
Normal file
23
graphene/types/json.py
Normal file
|
@ -0,0 +1,23 @@
|
|||
from __future__ import absolute_import
|
||||
|
||||
import json
|
||||
from graphql.language import ast
|
||||
|
||||
from .scalars import Scalar
|
||||
|
||||
|
||||
class JSONString(Scalar):
|
||||
'''JSON String'''
|
||||
|
||||
@staticmethod
|
||||
def serialize(dt):
|
||||
return json.dumps(dt)
|
||||
|
||||
@staticmethod
|
||||
def parse_literal(node):
|
||||
if isinstance(node, ast.StringValue):
|
||||
return json.dumps(node.value)
|
||||
|
||||
@staticmethod
|
||||
def parse_value(value):
|
||||
return json.dumps(value)
|
Loading…
Reference in New Issue
Block a user