owen777
Binge Watcher
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-13-2018
05:13 AM
Default assocarray field's value
Hey, what's the correct way of setting default assocarray field's value in XML? Is there any? I'm able to set only an empty object via:
but none of the following works:
I need to set such default value inside field's declaration because if I'm setting it in inside the init() function, from time to time, when trying to get "headers" field value right after object creation, it's Invalid.
<field id="headers" type="assocarray" value="{}" />
but none of the following works:
<field id="headers" type="assocarray" value="{test: value}" />
<field id="headers" type="assocarray" value='{test: "value"}' />
<field id="headers" type="assocarray" value='{"test": "value"}' />
<field id="headers" type="assocarray" value="{test: \"value\"}" />
<field id="headers" type="assocarray" value="{\"test\": \"value\"}" />
I need to set such default value inside field's declaration because if I'm setting it in inside the init() function, from time to time, when trying to get "headers" field value right after object creation, it's Invalid.
7 REPLIES 7
joetesta
Roku Guru
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-15-2018
01:14 PM
Re: Default assocarray field's value
Could you:
- set the value from the place where you are getting the headers or,
- put an invalid check with a reasonable fallback or,
- recheck on a timer?
aspiring
owen777
Binge Watcher
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-16-2018
03:34 AM
Re: Default assocarray field's value
@joetesta that would be a workaround. Hence it's not mentioned in the docs it's impossible to set default values for few specific types of a field, then it should be allowed. The question is how to do this.
If it's impossible, the docs should be updated. If Roku only moves its docs to a public repository, we could participate in updating them via pull requests, but obviously nobody from Roku will even answer this question, let alone open the docs.
If it's impossible, the docs should be updated. If Roku only moves its docs to a public repository, we could participate in updating them via pull requests, but obviously nobody from Roku will even answer this question, let alone open the docs.
joetesta
Roku Guru
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-16-2018
08:03 AM
Re: Default assocarray field's value
sorry
aspiring


Roku Employee
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-18-2018
11:22 AM
Re: Default assocarray field's value
"owen777" wrote:
Hey, what's the correct way of setting default assocarray field's value in XML? Is there any? I'm able to set only an empty object via:<field id="headers" type="assocarray" value="{}" />
but none of the following works:<field id="headers" type="assocarray" value="{test: value}" />
<field id="headers" type="assocarray" value='{test: "value"}' />
...
To embed a double quotation mark (") in an XML attribute, you need to escape it as """
E.g.
<field id="headers" type="assocarray" value="{myint: 123, mystr:"abc"}" />
should work to set headers = {myint:123, mystr:"abc"}
owen777
Binge Watcher
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-30-2018
03:44 AM
Re: Default assocarray field's value
"RokuKC" wrote:
To embed a double quotation mark (") in an XML attribute, you need to escape it as """
E.g.<field id="headers" type="assocarray" value="{myint: 123, mystr:"abc"}" />
should work to set headers = {myint:123, mystr:"abc"}
Not really:
<field id="headers" type="assocarray" value="{"Content-Type": "application/json", "Accept": "application/json"}" />
breaks the app
joetesta
Roku Guru
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-30-2018
08:42 AM
Re: Default assocarray field's value
I think assocarray can't have quoted key, did you try:
<field id="headers" type="assocarray" value="{Content-Type: "application/json", Accept: "application/json"}" />
aspiring


Roku Employee
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-30-2018
03:30 PM
Re: Default assocarray field's value
"owen777" wrote:
Not really:<field id="headers" type="assocarray" value="{"Content-Type": "application/json", "Accept": "application/json"}" />
breaks the app
I confirm, that appears to be a bug in the RSG support. I've filed a ticket to report this.
Unfortunately "Content-Type" is not a valid unquoted identifier, so it can't be used in the XML field value as an AA key name without quoting.