eXept Software AG Logo

Smalltalk/X Webserver

Documentation of class 'JSONTypeEncoder::STXTypeEncoder3':

Home

Documentation
www.exept.de
Everywhere
for:
[back]

Class: STXTypeEncoder3 (private in JSONTypeEncoder

This class is only visible from within JSONTypeEncoder.

Inheritance:

   Object
   |
   +--JSONTypeEncoder
      |
      +--JSONTypeEncoder::STXTypeEncoder3

Package:
stx:goodies/communication
Category:
Net-Communication-JSON
Owner:
JSONTypeEncoder

Description:


I encode/decode objects as a composite,
consisting of separate type and ref composites wrapping actual
objects.
I can store and reconstruct recursive objects.


Class protocol:

queries
o  typeInfoFormat


Instance protocol:

accessing
o  canRepresentAnyObject

o  canRepresentRecursiveObjects

o  idSlotName
to overwrite the slotName which provides the id
(if not set, defaults to @id)

o  refSlotName
to overwrite the slotName which provides the ref information
(if not set, defaults to @ref)

o  typeSlotName
to overwrite the slotName which provides the type information
(if not set, defaults to @type)

o  valueSlotName
to overwrite the slotName which provides the type information
(if not set, defaults to @value)

protocol
o  decodeDictionary: aJSONObject
this one expects a slot containing @t (typeSlotKey) and @v (valueSlotKey)
and possibly a @id

o  encodeDictionary: aDictionary indent: indent on: aStream using: actionForStandardEncoding
need more info if its not a Dictionary or if the keys are not all strings.

o  encodeHelper: anObject on: aStream do: aBlock
helper: checks if anObject has already been stored, then outputs a @ref dictionary.
Otherwise, outputs a dictionary containing @id, @type and the object's actual slot values.
aBlock is meant to store the actual contents - this must match what the reader expects
for that particular type (see visiting protocol)

o  encodeObject: anObject skipNil: skipNil indent: indent on: aStream

o  encodeSequenceableCollection: aCollection indent: indent on: aStream using: actionForStandardEncoding

o  encodeSet: aSet indent: indent on: aStream using: actionForStandardEncoding
self encodeObject:v skipNil:false indent:indent on:aStream.

visiting (decoding)
o  visitDictionary: inst with: jsonValues
this was either written as a standard JSON dictionary
(if there where only string keys),
or as a special key-value array (if there where non-string keys,
or the dictionary was an identity dict).
See encodeDictionary: here

o  visitObject: inst with: jsonValues

o  visitSequenceableCollection: inst with: jsonValues

o  visitSet: inst with: jsonValues



ST/X 7.7.0.0; WebServer 1.702 at 20f6060372b9.unknown:8081; Mon, 18 Nov 2024 06:56:58 GMT