-
Notifications
You must be signed in to change notification settings - Fork 10
Bugfix 20245 #10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
mwieder
wants to merge
3
commits into
montegoulding:master
Choose a base branch
from
mwieder:bugfix_20245
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Bugfix 20245 #10
Changes from 1 commit
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,9 +4,9 @@ on revLoadLibrary | |
| if the target is not me then | ||
| pass revLoadLibrary | ||
| end if | ||
|
|
||
| insert the script of me into back | ||
|
|
||
| if the environment contains "development" then | ||
| set the _ideoverride of me to true | ||
| end if | ||
|
|
@@ -16,7 +16,7 @@ on revUnloadLibrary | |
| if the target is not me then | ||
| pass revUnloadLibrary | ||
| end if | ||
|
|
||
| remove the script of me from back | ||
| end revUnloadLibrary | ||
|
|
||
|
|
@@ -52,31 +52,35 @@ pJSON (string): A UTF8 encoded JSON string | |
| Returns: A LiveCode array | ||
|
|
||
| Description: | ||
| JSON arrays are translated to LiveCode numerically indexed arrays | ||
| JSON arrays are translated to LiveCode numerically indexed arrays | ||
| with keys 1...N and JSON objects are translated to LiveCode array | ||
| key -> value pairs. | ||
|
|
||
| */ | ||
|
|
||
| function JSONToArray pJSON | ||
| local tArray,tRecurse, tKeys | ||
|
|
||
| put mergJSONDecode(pJSON,"tArray") into tRecurse | ||
| if tArray is an array then | ||
| put the keys of tArray into tKeys | ||
|
|
||
| split tRecurse by return as set | ||
| repeat for each line tKey in tKeys | ||
| if tRecurse[tKey] then | ||
| put JSONToArray(tArray[tKey]) into tArray[tKey] | ||
| else | ||
| put textDecode(tArray[tKey],"UTF8") into tArray[tKey] | ||
| end if | ||
| end repeat | ||
|
|
||
| return tArray | ||
|
|
||
| if pJSON is not empty then | ||
| put mergJSONDecode(pJSON,"tArray") into tRecurse | ||
| if tArray is an array then | ||
| put the keys of tArray into tKeys | ||
|
|
||
| split tRecurse by return as set | ||
| repeat for each line tKey in tKeys | ||
| if tRecurse[tKey] then | ||
| put JSONToArray(tArray[tKey]) into tArray[tKey] | ||
| else | ||
| put textDecode(tArray[tKey],"UTF8") into tArray[tKey] | ||
| end if | ||
| end repeat | ||
|
|
||
| return tArray | ||
| else | ||
| return textDecode(tArray,"UTF8") | ||
| end if | ||
| else | ||
| return textDecode(tArray,"UTF8") | ||
| return empty | ||
| end if | ||
| end JSONToArray | ||
|
|
||
|
|
@@ -90,7 +94,7 @@ ask question "What do you want to send?" | |
| if it is not empty then | ||
| put it into tMessage["text"] | ||
| put ArrayToJSON(tMessage) into tMessage | ||
|
|
||
| set the httpHeaders to "Content-type: application/json" | ||
| post tMessage to url kSlackWebhookURL | ||
| end if | ||
|
|
@@ -113,14 +117,18 @@ translated to JSON objects. | |
| */ | ||
|
|
||
| function ArrayToJSON pArray,pForceRootType,pPretty | ||
| repeat for each key tKey in pArray | ||
| if pArray[tKey] is an array then | ||
| put "}"&ArrayToJSON(pArray[tKey],pForceRootType) into pArray[tKey] | ||
| else if char 1 of pArray[tKey] = "}" then | ||
| put "}}" before pArray[tKey] | ||
| else | ||
| put textEncode(pArray[tKey],"UTF8") into pArray[tKey] | ||
| end if | ||
| end repeat | ||
| return(mergJSONEncode("pArray",pForceRootType,pPretty)) | ||
| if pArray is not empty then | ||
| repeat for each key tKey in pArray | ||
| if pArray[tKey] is an array then | ||
| put "}"&ArrayToJSON(pArray[tKey],pForceRootType) into pArray[tKey] | ||
| else if char 1 of pArray[tKey] = "}" then | ||
| put "}}" before pArray[tKey] | ||
| else | ||
| put textEncode(pArray[tKey],"UTF8") into pArray[tKey] | ||
| end if | ||
| end repeat | ||
| return(mergJSONEncode("pArray",pForceRootType,pPretty)) | ||
| else | ||
| return empty | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hmm... empty is invalid JSON..... so I'm not convinced this is a good idea |
||
| end if | ||
| end ArrayToJSON | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mwieder I'm fairly sure this is wrong and should be
if pArray is an array then