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

Data property on Sequence is a List<object> #100

Closed
ncipollina opened this issue Feb 6, 2023 · 7 comments
Closed

Data property on Sequence is a List<object> #100

ncipollina opened this issue Feb 6, 2023 · 7 comments

Comments

@ncipollina
Copy link

Currently, the Sequence component has the Data property defined as APLValue<List<object>>. This will work great when I want to provide the data as a list of objects. But for the scenario where I want to reference a datasource because I'm using a transformer, this won't work because I need to be able to provide a string. Something like this:

  {
      "type": "Sequence",
      "id": "leaderboardSequence",
      "width": "100%",
      "height": "80%",
      "data": "${payload.leaderboardData.properties.listItems}",
      "numbered": true,
      "items": [

Ideally it would be nice to be able to support both a list of objects and a string so I can define this either way.

@stoiveyp
Copy link
Owner

stoiveyp commented Feb 7, 2023

Morning @ncipollina - All APLValue objects should be able to be represented as strings using the .To(string) method

I'm at work so I can't check the exact code right now, but if you take a look it should be something like APLValue<List<object>>.To("${payload.leaderboardData.properties.listItems}")

Let me know if that helps?

@ncipollina
Copy link
Author

@stoiveyp thanks for the reply. I tried that and it ended up outputting this:

   {
      "type": "Sequence",
      "id": "leaderboardSequence",
      "width": "100%",
      "height": "80%",
      "data": ["${payload.leaderboardData.properties.listItems}"],
      "numbered": true,
      "items": [

That theoretically should have worked, but it just generated an error.

@stoiveyp
Copy link
Owner

stoiveyp commented Feb 7, 2023

hmm it shouldn't have put it in the array, it should have referenced the string directly.
Are you able to paste just the line you use to set that Data property please and I'll take a look tonight to see what's happening

@ncipollina
Copy link
Author

Sure. It was like this:

Data = new List<object>{ "${payload.leaderboardData.properties.listItems}" };

@stoiveyp
Copy link
Owner

stoiveyp commented Feb 7, 2023

That's great, thank you.

As I can't get to it for hours yet (it's 1pm here and I won't be free until 9/10pm earliest) could you try the following line of code as an alternative and see if this changes the output at all?

Data = APLValue<List<object>>.To("${payload.leaderboardData.properties.listItems}");

Just want to see if that produces something more useable - if not then I'll debug when I'm available tonight 👍

@ncipollina
Copy link
Author

I'll give it a try. Thanks!

@ncipollina
Copy link
Author

Ok, that did the trick! I'll close this issue.

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