lotusscript - NotesJSONNavigator 在解析具有空字符串值的包时遇到严重问题
问题描述
我正在使用新的 NotesJSONNavigator 对象来解析来自第三方 API 的响应。我观察到的响应看起来格式正确(JSON),但我的代码吐出了一些奇怪的结果。
我将其缩小到由空字符串表示的 JSON 值。在这些情况下,从 JSON 中检索到的“值”是不可预测的和随机的(系统字符)。
我准备了一个示例测试 JSON 包字符串,并且可以使用以下逻辑可靠地重现结果......我在这里遗漏了什么吗?
response$ = |{"resultcode":200,"result":[{"id":41,"eMail Address":"test@abc.com"},{"id":57,"eMail Address":""}]}|
Set jsonNav = session.CreateJSONNavigator( response$ )
Set jsonEl = jsonNav.GetElementByName( "result" )
Set jsonArr = jsonEl.Value
Set listEl = jsonArr.GetFirstElement()
Do While Not( listEl Is Nothing )
Set jsonObj = listEl.Value
checkEmail = jsonObj.GetElementByName( "eMail Address" ).Value
Set listEl = jsonArr.GetNextElement()
Loop
只要“电子邮件地址”部分中有数据,一切都解析得很好。如果该数据是一个空字符串(如上面的 ID 57),则 checkEmail 变量被设置为一些非常奇怪的字符并且不是空白的!
解决方案
推荐阅读
- android - RecyclerView.Adapter 从 URL 加载图像没有得到更新
- python - Python 3.5 - ModuleNotFoundError:没有名为“tensorflow”的模块
- rabbitmq - 如何使用 Jhipster 使用 RabbitMQ 创建一个新队列?
- ruby-on-rails - Rails 在零时将计数复数,不适用于 number_with_delimiter 方法
- protocol-buffers - 如何在 Python protobuf 中通过 Fieldmask 屏蔽地图字段?
- javascript - 恢复蓝牙设备地址
- asterisk - 宏的替代方案
- angular - 使用 RxJ 有条件地合并两个流
- python - Keras ImageDataGenerator.flow_from_dataframe 继续加载
- python - 是否可以将训练 DataLoader(和数据集)拆分为训练和验证数据集?