NULL support when interchanging data between structs and json objects would be desirable. At present when moving data from a json object into a struct we can ignore json members that don’t have a matching element in the struct by using the property pbRequireAllMembers. If we had something similar when moving data from a struct into a json object it would avoid the manual coding you speak of Andrew (and others).

The example below is what currently happens (which of course is perfectly acceptable).

Code:
Struct tStudentDetail
    Date    birthday
    Integer age
    Boolean male
    String  scholar
End_Struct

Struct tStudent
    String name
    tStudentDetail details
    Number[] ratings
End_Struct


Procedure Struct2Json
    tStudent Student
    String sText
    Handle hoJson
    
    Move "George" To Student.name
    Move 10/24/2000 To Student.details.birthday
//    Move 18 To Student.details.age
    Move True To Student.details.male
//    Move "N" To Student.details.scholar
//    Move 6.7 To Student.ratings[0]
//    Move 8.9 To Student.ratings[1]

    Get Create (RefClass(cJsonObject)) to hoJson
    Send DataTypeToJson Of hoJson Student
    Set peWhitespace Of hoJson To jpWhitespace_Pretty
    Get Stringify Of hoJson To sText
    Send Destroy Of hoJson
    
//    {
//       "name": "George",
//       "details": {
//         "birthday": "2000-10-24",
//         "age": 0,
//         "male": true,
//         "scholar": ""
//       },
//       "ratings": [
//       ]
//     }
End_Procedure
However, in many instances we only want to know what has been filled out in the struct. If there was a new method, let’s say NullInitialisedStructElements, then the json object would look something like this.

Code:
Procedure Struct2Json2
    tStudent Student
    String sText
    Handle hoJson

    Move (NullInitialisedStructElements(Student)) To Student
    Move "George" To Student.name
    Move True To Student.details.male
    
    Get Create (RefClass(cJsonObject)) To hoJson
    Send DataTypeToJson Of hoJson Student
    Set peWhitespace Of hoJson To jpWhitespace_Pretty
    Get Stringify Of hoJson To sText
    Send Destroy Of hoJson
    
//    {
//        "name": "George",
//        "details": {
//            "birthday": null,
//            "age": null,
//            "male": true,
//            "scholar": null
//        },
//        "ratings": [
//            null
//        ]
//    }
End_Procedure
Taking it a step further, with the addition of a new property, let’s say pbIgnoreNullStructElements, it would drop elements that had not been filled out, i.e. those set to null, when moving a struct into a json object. E.g.

Code:
Procedure Struct2Json2
    tStudent Student
    String sText
    Handle hoJson

    Move (NullInitialisedStructElements(Student)) To Student
    Move "George" To Student.name
    Move True To Student.details.male
    
    Get Create (RefClass(cJsonObject)) To hoJson
    Set pbIgnoreNullStructElements Of hoJson To True
    Send DataTypeToJson Of hoJson Student
    Set peWhitespace Of hoJson To jpWhitespace_Pretty
    Get Stringify Of hoJson To sText
    Send Destroy Of hoJson
    
//    {
//        "name": "George",
//        "details": {
//            "male": true
//        }
//    }
End_Procedure