Skip to content
New issue

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

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

Already on GitHub? # to your account

Parsing "flat" JSON #38

Open
kapi2289 opened this issue Apr 20, 2019 · 0 comments
Open

Parsing "flat" JSON #38

kapi2289 opened this issue Apr 20, 2019 · 0 comments

Comments

@kapi2289
Copy link

I have an example JSON

{
	"id": 1,
	"test1": 2,
	"test2": 3,
	"child1_id": 6,
	"child1_name": "Test",
	"child2_id": 8,
	"child2_name": "Test2",
}

and I want to have models

@related.immutable
class Child1:
    id = related.IntegerField(key="child1_id")
    name = related.StringField(key="child1_name")


@related.immutable
class Child2:
    id = related.IntegerField(key="child2_id")
    name = related.StringField(key="child2_name")


@related.immutable
class Parent:
    id = related.IntegerField()
    test1 = related.IntegerField()
    test2 = related.IntegerField()
    child1 = related.ChildField(Child1)
    child2 = related.ChildField(Child2)

How can I do this?

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

No branches or pull requests

1 participant