Apache Thrift: Assign default values to enclosed struct

7.3k views Asked by At

In an IDL file, I have

struct CaseInfo {
    1: CaseID = '',
    2: EvID = 'foobar',
}

struct Case {
    1: CaseInfo CaseInfo,
    2: string key = '',
}

When an instance of a Case object is created, CaseInfo is simply null; it doesn't contain a default CaseInfo object. What is the syntax for setting the defaults of such an object?

1

There are 1 answers

0
David On

It looks like you can initialize default values for structs via a json style map of field names to values. E.g.

struct Case{
    1: CaseInfo CaseInfo = {"CaseID": "", "EvID": "foobar"},
    2: string key = ""
}