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

Parsing array response from server #18

Open
dkrusenstrahle opened this issue Oct 4, 2013 · 1 comment
Open

Parsing array response from server #18

dkrusenstrahle opened this issue Oct 4, 2013 · 1 comment

Comments

@dkrusenstrahle
Copy link

Hello,

I am trying to parse this output (from an API):

{
"code": 200,
"total": 1,
"projects": [
{
"project": {
"id": 4,
"title": "rebuilding school",
"description": "Rebuilding of the school diner.",
"created_at": "2013-09-24T15:59:10Z",
"total_tasks": 2
}
}
]
}

I tried both this:

"parentNode": "projects.project",

and I have tried this:

"parentNode": "projects[0]project",

None of them creates the model. How can I access the title, id and so on?

Thanks!

@viezel
Copy link
Owner

viezel commented Oct 5, 2013

look here: https://github.com/viezel/napp.alloy.adapter.restapi#nested-result-objects

You can either define the parent node, or specify a custom parsing function. In your example it would be

"parentNode": "projects"

Because each "project" is the item you want to parse, and therefore "projects" is the parent node.

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

No branches or pull requests

2 participants