github.com/anthropics/anthropic-sdk-go@v1.70.1/internal/apijson/field.go (about)

     1  package apijson
     2  
     3  type status uint8
     4  
     5  const (
     6  	missing status = iota
     7  	null
     8  	invalid
     9  	valid
    10  )
    11  
    12  type Field struct {
    13  	raw    string
    14  	status status
    15  }
    16  
    17  // Returns true if the field is explicitly `null` _or_ if it is not present at all (ie, missing).
    18  // To check if the field's key is present in the JSON with an explicit null value,
    19  // you must check `f.IsNull() && !f.IsMissing()`.
    20  func (j Field) IsNull() bool    { return j.status <= null }
    21  func (j Field) IsMissing() bool { return j.status == missing }
    22  func (j Field) IsInvalid() bool { return j.status == invalid }
    23  func (j Field) Raw() string     { return j.raw }