I have the following agent to test the new V10 JSON parser The json in the code is retrieved from the darksky weather api
Option Public
Option Declare
Sub Initialize
Dim json As String
Dim session As New NotesSession
json = |{
"latitude": 51.2747748,
"longitude": 4.4433923,
"timezone": "Europe/Brussels",
"daily": {
"summary": "Rain today, with high temperatures falling to 3øC next Sunday.",
"icon": "rain",
"data": [{
"time": 1547334000,
"summary": "Rain in the afternoon and breezy starting in the afternoon.",
"icon": "rain",
"sunriseTime": 1547365378,
"sunsetTime": 1547395251,
"moonPhase": 0.23,
"precipIntensity": 0.4115,
"precipIntensityMax": 1.5621,
"precipIntensityMaxTime": 1547380800,
"precipProbability": 0.97,
"precipType": "rain",
"temperatureHigh": 10.56,
"temperatureHighTime": 1547391600,
"temperatureLow": 5.5,
"temperatureLowTime": 1547449200,
"apparentTemperatureHigh": 10.56,
"apparentTemperatureHighTime": 1547391600,
"apparentTemperatureLow": 2.06,
"apparentTemperatureLowTime": 1547427600,
"dewPoint": 6.77,
"humidity": 0.87,
"pressure": 1009.48,
"windSpeed": 7.24,
"windGust": 17.26,
"windGustTime": 1547395200,
"windBearing": 285,
"cloudCover": 0.93,
"uvIndex": 1,
"uvIndexTime": 1547377200,
"visibility": 12.59,
"ozone": 311.57,
"temperatureMin": 7.17,
"temperatureMinTime": 1547416800,
"temperatureMax": 10.56,
"temperatureMaxTime": 1547391600,
"apparentTemperatureMin": 2.64,
"apparentTemperatureMinTime": 1547416800,
"apparentTemperatureMax": 10.56,
"apparentTemperatureMaxTime": 1547391600
}]
},
"offset": 1
}|
json = removeCRLF(json)
Dim jsnav As NotesJSONNavigator
Set jsnav = session.CreateJSONNavigator(json)
Dim el As NOTESJSONELEMENT
Set el = jsnav.getelementbypointer("/latitude")
Print CStr(el.value)
End Sub
Function removeCRLF(json) As String
removeCRLF =Replace(Replace(json, Chr(13), ""),Chr(10),"")
End Function
I get this error when running the agent:
Unable to Parse JSON string: Missing a comma or '}' after an object member. offset 1791
After some testing, I found out that the error is coming from a special character in the json (ø in '... falling to 3øC next ...').
Can anybody help me out on how to avoid/convert characters that could cause issues when parsing the JSON?
PS: The openntf JSON parser handles the json correctly.