Example #1
0
def get_object_as_json(o, cls, ignore_wrappers=True, complex_as=list,
                                            encoding='utf8', polymorphic=False):
    prot = JsonDocument(ignore_wrappers=ignore_wrappers, complex_as=complex_as,
                                                        polymorphic=polymorphic)
    ctx = FakeContext(out_document=[prot._object_to_doc(cls,o)])
    prot.create_out_string(ctx, encoding)
    return ''.join(ctx.out_string)
Example #2
0
def get_object_as_json(o, cls=None, ignore_wrappers=True, complex_as=list, encoding="utf8", polymorphic=False):
    if cls is None:
        cls = o.__class__

    prot = JsonDocument(ignore_wrappers=ignore_wrappers, complex_as=complex_as, polymorphic=polymorphic)
    ctx = FakeContext(out_document=[prot._object_to_doc(cls, o)])
    prot.create_out_string(ctx, encoding)
    return "".join(ctx.out_string)
Example #3
0
def get_object_as_json_doc(o, cls=None, ignore_wrappers=True, complex_as=list,
                                      polymorphic=False, indent=None, **kwargs):
    if cls is None:
        cls = o.__class__

    prot = JsonDocument(ignore_wrappers=ignore_wrappers, complex_as=complex_as,
                               polymorphic=polymorphic, indent=indent, **kwargs)

    return prot._object_to_doc(cls, o)
Example #4
0
def get_object_as_json(o, cls=None, ignore_wrappers=True, complex_as=list,
                     encoding='utf8', polymorphic=False, indent=None, **kwargs):
    if cls is None:
        cls = o.__class__

    prot = JsonDocument(ignore_wrappers=ignore_wrappers, complex_as=complex_as,
                               polymorphic=polymorphic, indent=indent, **kwargs)
    ctx = FakeContext(out_document=[prot._object_to_doc(cls, o)])
    prot.create_out_string(ctx, encoding)
    return b''.join(ctx.out_string)
Example #5
0
def get_object_as_json(o, cls, ignore_wrappers=True, complex_as=list, encoding="utf8"):
    prot = JsonDocument(ignore_wrappers=ignore_wrappers, complex_as=complex_as)
    ctx = FakeContext(out_document=[prot._object_to_doc(cls, o)])
    prot.create_out_string(ctx, encoding)
    return "".join(ctx.out_string)