Quantcast
Channel: West Wind Message Board Messages
Viewing all articles
Browse latest Browse all 10393

Re: wwJSONSerializer

$
0
0
Re: wwJSONSerializer
Web Connection 5.0
Re: wwJSONSerializer
Mar. 21, 2013
09:28 am
3QR0KBPXEShow this entire thread in new window
Gratar Image based on email address
From:Michael Hogan (Ideate Hosting)
To:Rick Strahl
How would one construct an object representing several master/detail (one to many) records - each with several related records? Nested arrays? Nested Collections?

Seems overly complicated... but perhaps I'm missing something. Perhaps you can point to an example... Eager to learn.

What I ended up doing is generating JSON for the master records, and then looping through to create a child records cursor for each master record, generating JSON from that, and using StringReplace() to insert the children into the master JSON string:

SELECT ..., "Images4"+Listings.ListCode AS Images ;FROM ./Condo/Listings ; INTO CURSOR TQuery READWRITE lcReturnValue = loSerializer.Serialize("cursor:TQuery")SCANSELECT ..., TRANSFORM(ImageList.ImgCode) + [.] + ALLTRIM(ImageList.ImgType) AS ImgSrc ;FROM ImageList ; WHERE ImageList.ListCode = TQuery.ListCode ; INTO CURSOR TImageList* Extract to JSON lcImageList = loSerializer.Serialize("cursor:TImageList") lcImageList = STRTRAN(lcImageList,["Rows"],["image"]) lcTextToReplace = ["Images4] + TQuery.ListCode + ["] lcReturnValue = STRTRAN(lcReturnValue,lcTextToReplace,lcImageList)SELECT TQueryENDSCAN


You should be able to keep using it.

When you say nesting what do you mean though? Can't you just construct one Fox object and then serialize the whole thing at once?

+++ Rick ---



I'm going to be nesting some JSON strings. Do I need to Destroy and re-create wwJSONSerializer for each pass with a newly populated cursor, or can I just repeatedly call Serialize() and get clean results from the object?

TIA





Viewing all articles
Browse latest Browse all 10393

Trending Articles