<commit_before>package main

import (
	"bytes"
	"database/sql"
	"database/sql/driver"
	"encoding/json"
	"reflect"

	"github.com/lib/pq"
)

func NewContact() *Contact {
	return &Contact{}
}

type Contact struct {
	Id          sql.NullInt64
	Email       sql.NullString
	FirstName   sql.NullString
	LastName    sql.NullString
	MiddleName  sql.NullString
	DateOfBirth pq.NullTime
	Sex         sql.NullInt64
}

func (c Contact) MarshalJSON() (res []byte, err error) {
	defer func() {
		if e := recover(); e != nil {
			if ee, ok := e.(error); ok {
				err = ee
			}
		}
	}()

	buffer := bytes.NewBuffer([]byte("{"))

	rtype := reflect.TypeOf(&c).Elem()
	rval := reflect.ValueOf(&c).Elem()
	count := rtype.NumField()

	result := make([][]byte, 0)

	for i := range make([]struct{}, count) {
		key := rtype.Field(i)
		value := rval.Field(i).Interface()
		if val, ok := value.(driver.Valuer); ok {
			if v, err := val.Value(); v != nil && err == nil {
				if vJson, err := json.Marshal(v); err == nil {
					res := []byte(`"`)
					res = append(res, []byte(key.Name)...)
					res = append(res, []byte(`":`)...)
					res = append(res, vJson...)
					result = append(result, res)
				}
			}
		}
	}

	jsonData := bytes.Join(result, []byte(","))
	if _, err = buffer.Write(jsonData); err != nil {
		return
	}

	if _, err = buffer.Write([]byte(`}`)); err != nil {
		return
	}

	return buffer.Bytes(), err
}<commit_msg>Update Contact struct<commit_after>package main

import (
	"database/sql"

	"github.com/lib/pq"
)

func NewContact() *Contact {
	return &Contact{}
}

type Contact struct {
	Id          sql.NullInt64
	Email       sql.NullString
	FirstName   sql.NullString
	LastName    sql.NullString
	MiddleName  sql.NullString
	DateOfBirth pq.NullTime
	Sex         sql.NullInt64
	Profiles    []*Profile
}

func (c *Contact) MarshalJSON() ([]byte, error) {
	return MarshalJSON(c)
}
{'fraction_non_alphanumeric': 0.17086234600964115, 'fraction_numerical': 0.0048205677557579, 'mean_word_length': 3.0258620689655173, 'pattern_counts': {'":': 1, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1251598', 'n_tokens_mistral': 738, 'n_tokens_neox': 674, 'n_words': 163}