Notes项目中无法同时使用两个JSON LotusScript类库的问题求助
Hey there! Let's work through that conflict between JSONReader and JSONWrapperConverters in your LotusScript JSON setup. I've dealt with this exact issue using the same library, so here's what you need to know:
Why You're Seeing the Conflict
The two components rely on separate internal parsing/serialization contexts—mixing them tries to reuse or overwrite shared resources, which triggers errors. The fix is to pick one consistent workflow for parsing and serializing, no mixing allowed.
Option 1: Stick with JSONReader + JSONWriter
This is the more straightforward approach for direct JSON object manipulation:
- Parse the incoming string into a
JsonObjectorJsonArrayusingJSONReader:Dim jsonReader As New JSONReader() Dim jsonObj As JsonObject Set jsonObj = jsonReader.ParseString(yourJsonString) - Modify the JSON object as needed (add/update fields, adjust arrays):
jsonObj.Put("updatedField", "newValue") jsonObj.Remove("oldField") - Serialize back to string using
JSONWriter:Dim jsonWriter As New JSONWriter() Dim outputJson As String outputJson = jsonWriter.WriteToString(jsonObj)
Don't forget to clean up your objects with Set jsonReader = Nothing and Set jsonWriter = Nothing when done to avoid lingering context issues.
Option 2: Use JSONWrapperConverters Exclusively
If you prefer working with wrapped objects (which can feel more "Notes-like"), stick to the converter methods end-to-end:
- Parse the string into a wrapped JSON object:
Dim converter As New JSONWrapperConverters() Dim wrappedObj As JSONWrapperObject Set wrappedObj = converter.JsonStringToWrapper(yourJsonString) - Manipulate the wrapped object:
Call wrappedObj.Put("newKey", "updatedValue") Call wrappedObj.Delete("obsoleteKey") - Convert back to string:
Dim outputJson As String outputJson = converter.WrapperToJsonString(wrappedObj)
Pro Tips
- Make sure you're using the latest version of the JSON LotusScript Classes—older versions had more context-related bugs that caused this kind of conflict.
- If you ever need to convert between the two object types, use the converter's helper methods instead of trying to mix readers/writers directly.
内容的提问来源于stack exchange,提问作者J.Nick

