Hi everyone.
I've got a problem with a struct for JSON in SIL script.
To read JSON via httpGet() from http://{my.jira}/rest/tempo-core/1/holidayscheme/{id}/days/floating i need structrure like this :
struct HolidayDay
{
number id;
number schemeId;
string name;
string description;
string duration;
string type;
string date;
}
but I have an error on the line : string date;, becouse date is one of internal type in SIL.
When I rename string name to string name_, httpGet doesn't read this property.
I need some solution how to read this properly.
Hi,
First, thank you for pointing this out for us, having a field with the same name as a SIL reserved keyword is indeed a limitation that we didn't consider.
We are going to fix this. However, in order to have better visibility of the process, I would kindly advise you to also create a ticket with this issue in our Service Desk support portal: https://jira.cprime.io/servicedesk/customer/portal/2
This way you will also be able to receive the quick fix before our next official release.
Best Regards,
Cristian Pintea
Hi @f2997042, while we work on fixing this bug you can try a workaround like this:
struct HolidayDay
{
number id;
number schemeId;
string name_;
string description;
string duration;
string type;
string date_;
}
HolidayDay hd;
hd.id = 1;
hd.schemeId = 123;
hd.name_ = "Name";
hd.description = "Test";
hd.duration = "24h";
hd.type = "Test";
hd.date_ = "06/12/2018";
string json = toJson(hd);
json = replace(json, "name_", "name");
json = replace(json, "date_", "date");
httpGet(requestURL, request, json);
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Was there ever a more permanent solution provided to this? Or is this still the accepted workaround?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Jon Kovalik we were able to fix some of the occurrences like this. For example, "name" could work in the regular manner now. However, we were not able to fix reserved words like "date" because it is a variable type and we couldn't have it work different ways in essentially the same scenario.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
We do have a long-term solution on the roadmap that would let you parse the JSON without defining it as a struct first. I think ultimately this will be the ideal solution.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I'm trying to parse a field called "date" and the workaround noted above was not working for me. I'm not sure what my options are at this point to be able to read in that field. Thoughts?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Jonathan Muse _Appfire_ - can you define how far out the "long-term solution" would be? The inability to parse a field called date is going to be a headache for us as our initial use case falls into this category.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.