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

Unable to deserialize sample RenderDocument #29

Closed
NiteLordz opened this issue Dec 25, 2018 · 7 comments
Closed

Unable to deserialize sample RenderDocument #29

NiteLordz opened this issue Dec 25, 2018 · 7 comments

Comments

@NiteLordz
Copy link

If you go here and try the sample "Long text" then export the code.

when you try to deserialize that json you get an error of

Cannot deserialize the current JSON object (e.g. {"name":"value"}) into type 'System.Collections.Generic.IList`1

for the property "fontWeight" as it is a single element and not a list element.

I tried to puta JsonObject attribute on the class, but it didn't resolve the issue.

@stoiveyp
Copy link
Owner

@NiteLordz thanks for raising this - I've resolved the deserialization issue in 2.1.0 which is now in NuGet.

There was a secondary issue with the long text example as the library didn't support simple parameters, that's been fixed as well.

Hope this helps.

@NiteLordz
Copy link
Author

@stoiveyp
Document is now deserializing without the exception, however, I am still having an issue with nested items. It works fine if only one level of items, but if it is nested, then the nested items do not show up.

sample serialized render document directive below

{"document":{"type":"APL","version":"1.0","theme":"dark","import":[{"name":"alexa-layouts","version":"1.0.0"}],"resources":[{"description":"Stock color for the light theme","colors":{"colorTextPrimary":"#151920"}},{"description":"Stock color for the dark theme","when":"${viewport.theme == 'dark'}","colors":{"colorTextPrimary":"#f0f1ef"}},{"description":"Standard font sizes","dimensions":{"textSizeBody":48,"textSizePrimary":27,"textSizeSecondary":23,"textSizeSecondaryHint":25}},{"description":"Common spacing values","dimensions":{"spacingThin":6,"spacingSmall":12,"spacingMedium":24,"spacingLarge":48,"spacingExtraLarge":72}},{"description":"Common margins and padding","dimensions":{"marginTop":40,"marginLeft":60,"marginRight":60,"marginBottom":40}}],"styles":{"textStyleBase":{"description":"Base font description; set color and core font family","values":[{"color":"@colorTextPrimary","fontFamily":"Amazon Ember"}]},"textStyleBase0":{"description":"Thin version of basic font","extend":"textStyleBase","values":{"fontWeight":"100"}},"textStyleBase1":{"description":"Light version of basic font","extend":"textStyleBase","values":{"fontWeight":"300"}},"mixinBody":{"values":{"fontSize":"@textSizeBody"}},"mixinPrimary":{"values":{"fontSize":"@textSizePrimary"}},"mixinSecondary":{"values":{"fontSize":"@textSizeSecondary"}},"textStylePrimary":{"extend":["textStyleBase1","mixinPrimary"]},"textStyleSecondary":{"extend":["textStyleBase0","mixinSecondary"]},"textStyleBody":{"extend":["textStyleBase1","mixinBody"]},"textStyleSecondaryHint":{"values":{"fontFamily":"Bookerly","fontStyle":"italic","fontSize":"@textSizeSecondaryHint","color":"@colorTextPrimary"}}},"layouts":{},"mainTemplate":{"parameters":["payload"],"items":[{"when":"${viewport.shape == 'round'}","type":"Container","direction":"column","items":[{"type":"Image","source":"${payload.bodyTemplate7Data.backgroundImage.sources[0].url}","scale":"best-fill","position":"absolute","width":"100vw","height":"100vh"},{"type":"AlexaHeader","headerTitle":"${payload.bodyTemplate7Data.title}","headerAttributionImage":"${payload.bodyTemplate7Data.logoUrl}"},{"type":"Container","grow":1,"alignItems":"center","justifyContent":"center","items":[{"type":"Image","source":"${payload.bodyTemplate7Data.image.sources[0].url}","scale":"best-fill","width":"100vh","height":"70vw","align":"center"}]}]},{"type":"Container","items":[{"type":"Image","source":"${payload.bodyTemplate7Data.backgroundImage.sources[0].url}","scale":"best-fill","position":"absolute","width":"100vw","height":"100vh"},{"type":"AlexaHeader","headerTitle":"${payload.bodyTemplate7Data.title}","headerAttributionImage":"${payload.bodyTemplate7Data.logoUrl}"},{"type":"Container","direction":"row","paddingLeft":"5vw","paddingRight":"5vw","paddingBottom":"5vh","alignItems":"center","justifyContent":"center","items":[{"type":"Image","height":"75vh","width":"90vw","source":"${payload.bodyTemplate7Data.image.sources[0].url}","scale":"best-fill","align":"center"}]}]}]}},"dataSources":{"bodyTemplate7Data":{"type":"object","objectId":"bt7Sample","title":"Today's Daily Photo of Cheese","backgroundImage":{"contentDescription":null,"smallSourceUrl":null,"largeSourceUrl":null,"sources":[{"url":"https://d2o906d8ln7ui1.cloudfront.net/images/BT7_Background.png","size":"small","widthPixels":0,"heightPixels":0},{"url":"https://d2o906d8ln7ui1.cloudfront.net/images/BT7_Background.png","size":"large","widthPixels":0,"heightPixels":0}]},"image":{"contentDescription":null,"smallSourceUrl":null,"largeSourceUrl":null,"sources":[{"url":"https://d2o906d8ln7ui1.cloudfront.net/images/MollyforBT7.png","size":"small","widthPixels":0,"heightPixels":0},{"url":"https://d2o906d8ln7ui1.cloudfront.net/images/MollyforBT7.png","size":"large","widthPixels":0,"heightPixels":0}]},"logoUrl":"https://d2o906d8ln7ui1.cloudfront.net/images/cheeseskillicon.png","hintText":"Try, "Alexa, search for blue cheese""}}}

@stoiveyp
Copy link
Owner

@NiteLordz This was a great example - thank you. I made the example a test file as a RenderDocumentDirective to deserialize it as a single piece - and with the failed test I was able to publish v3.0.0
Style extensions can be strings or arrays - but were only arrays in the package, so that's fixed.
There was an issue deserializing APLValue when the type was a list (such as component items) and this has been fixed too.
Your hint text had unescaped quotes, so I had to alter that. But other than that and the directive type I had to add, the result matches your input and appears correct.
Hope this helps and you're having a good holiday period.

@NiteLordz
Copy link
Author

Getting much closer!!! Am now able to deserialize the document elements, however, Data sources do not deserialize.

In the unit tests, "RenderDocument.json" executes properly and has the Data Sources filled in.

However, if you substitute "KeefersExample" in, you will see that the data sources are not populated. Properties element is null.

This is another nested item.

Holiday week has been GREAAT!!! hope yours has been as well!

@stoiveyp
Copy link
Owner

@NiteLordz This one took a little longer as it's a mismatch to the documentation and the documentation still works, so I didn't want to break it.

Documentation says ObjectDataSource should honor a "properties" object for the data, but the designer is adding them dynamically at the top level. Both work - just means the path you use has .properties. or not.

I've added a TopLevelData property in 3.1.0 (just published) to allow for the designer approach, which means you can access the data in your data source through that. Properties is still there for any existing ObjectDataSources in use so it's not another breaking change.

@NiteLordz
Copy link
Author

NiteLordz commented Dec 26, 2018

@stoiveyp

Confirmed, and databinding is occuring! #Success #CloseThisIssue

Btw, send ya a twitter follow, had some other things wanted to talk to ya about, in a non GH arena lol.

@stoiveyp
Copy link
Owner

Brilliant news, thank you for sticking with it/me!
The designer/doc mismatch has bitten me more than a few times with APL, but it's just such a big thing we can't have missing support in Alexa.NET

I'll make sure you're on my twitter list 👍

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