Perspective special characters in property names / object keys

Hi, I have been using special characters in object keys / property names for some time now, but the designer will not let me create this, it has to be done via a binding/script.

Why does Designer not let me enter special characters for this, asking to determine if this functionality might be removed at some point and or if this is just a bug in designer and I continue to just use a script to create them.

Current use is for customising the download icon in the report viewer, without accessing the advanced stylesheet. I have it working but a script seem overkill for this use case, it would be much simpler if we could simply add a value call it –actionBarIconSize and give it a value.

Has anyone else possibly found a better way for creating properties like this?

1 Like

They are refused because they are not valid JSON. If you absolutely need to use maps with invalid such keys, get my Integration Toolkit and use its asMap() on Perspective arrays of pairs.

Or, perhaps, use sessionVarMap, pageVarMap, or viewVarMap to hold jython objects for use in Perspective.

Sigh... I really should put the tablet down on vacation...

1 Like

I would add this into a style class instead, if you can’t edit the stylesheet or theme files. Inject into one of the props with a large text field in the UI like box shadow. Use something like

; --var-name: blue; --var2: red

Then at least you can standardise it and call the styling something instead of having magic stuff everywhere

1 Like

Hey Phil, I’m confused about what’s invalid JSON here? I thought all codepoints except “, \, and control characters were allowed.

2 Likes

I would also appreciate the ability to use arbitrary strings as property keys.

With the expectation that if I have a key that is not supported via the dot accessor syntax, that I’ll need to use square bracket notation or a getter:

# Python
string = `{
  "key": "value",
  "20": "key of numeric string",
  "prop.test": "key with a period"
}`

obj = system.util.jsonDecode(string)

print obj["20"] # key of numeric string
print obj["prop.test"] # key with a period
// JavaScript
const string = `{
  "key": "value",
  "20": "key of numeric string",
  "prop.test": "key with a period"
}`

const obj = JSON.parse(string)

console.log(obj["20"]) // key of numeric string
console.log(obj["prop.test"]) // key with a period

Perspective’s own view.json schema uses keys that contain dots.

Also, this is already kinda supported (if you can find a way to force “invalid” keys into the property tree):

1 Like

Hmmm. I may have some studying to do.

Thanks Phil, I will have a look at you modules, They have been on my list for some time but never get that far haha.

Usually I haven’t needed anything special as this use case have always been used as a means to store some session data so was only runtime and never had any issues.

But in this case, for me to override the ccs var, it had to be done at this level, the style class was pulled in to early, then a IA component would override my style class and just thought it would be nice to be able to enter keys like this manually without having to use a script.

I tried this, as i would prefer this way as well, but turns out for the controlStyle on the report viewer, the style classes are loaded, then some IA Styles are loaded, which overrides my style class, then the individual controlStyle properties are loaded at the element level which was the only way to override that specific variable i needed.

1 Like