Substring a field inside of an array?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-25-2019 11:26 AM
I’m trying to substring the field $studySiteChecklist.checklist.lastUpdateDate but I can get it to keep the same output as the input.
Any ideas?
[{
"country": "a",
"studySiteChecklist": {
"checklist": [{
"lastUpdateDate": "2017-08-27T00:00:00Z",
"commentsIndicator": "0",
"comments": "0",
"yesNoIndicator": "0",
"questionNumber": "0",
"checkListNumer": "0",
"question": "0"
}, {
"lastUpdateDate": "2000-08-27T00:00:00Z",
"commentsIndicator": "0",
"comments": "0",
"yesNoIndicator": "0",
"questionNumber": "0",
"checkListNumer": "0",
"question": "0"
}]
}
}]
Output needed:
[{
"country": "a",
"studySiteChecklist": {
"checklist": [{
"lastUpdateDate": "2017-08-27",
"commentsIndicator": "0",
"comments": "0",
"yesNoIndicator": "0",
"questionNumber": "0",
"checkListNumer": "0",
"question": "0"
}, {
"lastUpdateDate": "2000-08-27",
"commentsIndicator": "0",
"comments": "0",
"yesNoIndicator": "0",
"questionNumber": "0",
"checkListNumer": "0",
"question": "0"
}]
}
}]
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-26-2019 05:03 AM
It is weird that it is concatenating to the existing value. Should the toString() be applied at the end? This is because substr() is already returning a string.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-26-2019 05:20 AM
I tried toString because lastUpdateDate was being returned the same way but as it was an Array.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-26-2019 05:25 AM
Then it must be something to do with the interaction of json with arrays. Probably the only way it would work is to delete the key value pair and insert it back again with the key value pair, but with the newly updated value and the key value remaining the same.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-26-2019 05:44 AM
Another aspect may be due to immutability property of the string object.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-26-2019 05:48 AM
Not sure, but I was able to get it to work with the first suggestion.
