Use string date in JSON struct - JIRA SIL

f2997042
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
December 5, 2018

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.

 

 

2 answers

1 accepted

0 votes
Answer accepted
Cristian Pintea December 6, 2018

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

2 votes
Jonathan Muse {Appfire}
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
December 6, 2018

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);
Jon Kovalik June 28, 2022

Was there ever a more permanent solution provided to this?  Or is this still the accepted workaround?

Jonathan Muse {Appfire}
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
June 30, 2022

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.

Jonathan Muse {Appfire}
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
June 30, 2022

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.

Jon Kovalik June 30, 2022

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?

Jon Kovalik July 5, 2022

@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.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events