2024 April Release

Struct FSCEXPEXT@1.1001:JSONStructFormat Permanent link for this heading

Formatting information for object classes or types, used with Value2JSON.

When generating JSON an object or an aggregate, the supplied format list is consulted. If the type of the value matches jsftype, the remaining properties specify how to format the JSON entry. If FSCEXPEXT@1.1001:jssimple is true, for object classes just the object address is generated, otherwise the property list from FSCEXPEXT@1.100:jsfproperties specifies the properties of the sub entry.

The following sample generates a list of two users in different JSON formats.
  JSONPropertyFormat[] properties = [
    { jpfattrdef: #usersurname, jpfname: "FamilyName" },
    { jpfattrdef: #userfirstname, jpfname: "FirstName" }
  ];
  JSONStructFormat[] simpleformat = [
    { jsftype: #User, jsfsimple: true }
  ];
  JSONStructFormat[] complexformat = [
    { jsftype: #User, jsfproperties: properties }
  ];

User[] users = FROM User u WHERE u.userlogname like '%0001%'; User[] twousers = [users[0], users[1]]; dictionary data; data.users = twousers; string standardJSON = cooobj.Value2JSON(twousers); string simpleJSON = cooobj.Value2JSON(twousers, , , simpleformat); string complexSON = cooobj.Value2JSON(twousers, , , complexformat); string dataJSON = cooobj.Value2JSON(data, , , complexformat);
result in the following JSON strings
standardJSON = [
  {"objaddress":"COO.1.506.1.1000074","objname":"Baumann0001 Christina"},
  {"objaddress":"COO.1.506.1.1000077","objname":"Owner0001 Michael"}
]
simpleJSON = [
  {"objaddress":"COO.1.506.1.1000074"},
  {"objaddress":"COO.1.506.1.1000077"}
]
complexJSON = [
  {"FamilyName":"Baumann0001", "FirstName":"Christina"},
  {"FamilyName":"Owner0001","FirstName":"Michael"}
]
dataJSON = {
  "users": [
   {"Family Name":"Baumann0001","First Name":"Christina"},
   {"Family Name":"Owner0001","First Name":"Michael"}
  ]
}

Properties Permanent link for this heading

Type

Property

Name

JSONPropertyFormat[]

jsfproperties

Element Formats

boolean

jsfsimple

Simple Format

ComponentObject

jsftype

Object Class or Type

Properties Permanent link for this heading


Element Formats (FSCEXPEXT@1.1001:jsfproperties) Permanent link for this heading

Additional list of properties

JSONPropertyFormat[] FSCEXPEXT@1.1001:jsfproperties


Simple Format (FSCEXPEXT@1.1001:jsfsimple) Permanent link for this heading

Generate address only

boolean FSCEXPEXT@1.1001:jsfsimple


Object Class or Type (FSCEXPEXT@1.1001:jsftype) Permanent link for this heading

Object class or type to be formatted

ComponentObject FSCEXPEXT@1.1001:jsftype not null

Additional Information