Created
March 29, 2017 17:47
-
-
Save iversond/67ddae8529ecbc2b4e20f417ae0cdf36 to your computer and use it in GitHub Desktop.
Process inbound JSON. Not very dynamic, but using some basic JSON types in PeopleCode to parse the message data.
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
method Process | |
/+ &_str as String +/ | |
/+ Returns Boolean +/ | |
/* Try using the JsonObject */ | |
Local JsonParser &parser = CreateJsonParser(); | |
Local boolean &status = &parser.Parse(&_str); | |
Local JsonObject &jo = &parser.GetRootObject(); | |
Local JsonArray &jArray = &jo.GetJsonArray("Updates"); | |
Local Record &m_email_stg = CreateRecord(Record.M_EMAIL_STG); | |
Local boolean &insResult; | |
Local boolean &result = True; | |
Local integer &j; | |
/* For each update array */ | |
Local integer &childCount = &jArray.Length(); | |
For &j = 1 To &childCount | |
Local JsonObject &arrElement = Null; | |
&arrElement = &jArray.GetJsonObject(&j); | |
If &arrElement.IsExist("EMPLID") Then | |
&m_email_stg.EMPLID.Value = &arrElement.GetString("EMPLID"); | |
End-If; | |
If &arrElement.IsExist("EMAILID") Then | |
&m_email_stg.EMAILID.Value = &arrElement.GetString("EMAILID"); | |
End-If; | |
If &arrElement.IsExist("USERIDALIAS") Then | |
&m_email_stg.USERIDALIAS.Value = &arrElement.GetString("USERIDALIAS"); | |
End-If; | |
&insResult = &m_email_stg.Insert(); | |
If &insResult = False Then | |
&result = False; | |
End-If | |
End-For; | |
Return &insResult; | |
end-method; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment