OpenNTF.org - JSON LotusScript Classes

My Links (Not logged in)
User Name Password
Advert: Your ad here

Hosted by Prominic.NET

   Project: JSON LotusScript Classes (Managed by Troy Reimer)
Actions:


Response
SubjectRe:Can I append a new object?
Created 07/02/2009 11:14 AM by Troy Reimer.
Modified<none> by <none>.
Body

Absolutely you can append a new object. In the example below, I also output the result to a string. To be able to do that you have to change the ls.snapps.JSONReader library to use the ls.snapps.JSONWrapperConverters instead of the JSONObject and JSONArray libraries.

Here is some example code:

Dim jsonReader As JSONReader
Dim sQuestion As String
Dim sReply As String
Dim jsonObject As JSONObject
Dim jsonNew As JSONObject
Dim jsonQuestion As JSONObject
Dim sResult As String

Set jsonReader = New JSONReader
sQuestion = |{"question": [{"dt": "09-6-30","user": "firstName lastName","sub": "subject","body": "bodytext","img": ""}]}|
Set jsonObject = jsonReader.Parse(sQuestion)

Set jsonQuestion = jsonObject.Items("question").Items(0)

sReply = |{"dt": "09-6-30","user": "firstName lastName","sub": "subject","body": "body","img": ""}|
Set jsonNew = jsonReader.Parse(sReply)

Call jsonQuestion.AddItem("reply", jsonNew)
sResult = jsonQuestion.ToJSON

Hope that helps.
-Troy


Feedback

Hide details for Parsed my existing JSON with the JS... (Joacim Boive on 07/02/2009 09:21:14 AM )Parsed my existing JSON with the JS... (Joacim Boive on 07/02/2009 09:21:14 AM )
. . Re:Can I append a new object? (Troy Reimer on 07/02/2009 11:14:35 AM )
Check out other projects
Switch to project: