<commit_before>package gocd

import (
	"encoding/json"
	"errors"
	"strconv"
)

// JSONString returns a string of this stage as a JSON object.
func (j *Job) JSONString() (body string, err error) {
	err = j.Validate()
	if err != nil {
		return
	}

	bdy, err := json.MarshalIndent(j, "", "  ")
	body = string(bdy)

	return
}

// Validate a job structure has non-nil values on correct attributes
func (j *Job) Validate() (err error) {
	if j.Name == "" {
		err = errors.New("`gocd.Jobs.Name` is empty")
	}
	return
}

func (tf *TimeoutField) UnmarshalJSON(b []byte) (err error) {
	value := string(b)
	var valInt int

	if value == `"never"` {
		valInt = 0
	} else {
		valInt, err = strconv.Atoi(value)
	}
	valTf := TimeoutField(valInt)
	tf = &valTf

	return
}

func (tf TimeoutField) MarshalJSON() (b []byte, err error) {
	return
}<commit_msg>Fixed parsing of Timeout field<commit_after>package gocd

import (
	"encoding/json"
	"errors"
	"strconv"
)

// JSONString returns a string of this stage as a JSON object.
func (j *Job) JSONString() (body string, err error) {
	err = j.Validate()
	if err != nil {
		return
	}

	bdy, err := json.MarshalIndent(j, "", "  ")
	body = string(bdy)

	return
}

// Validate a job structure has non-nil values on correct attributes
func (j *Job) Validate() (err error) {
	if j.Name == "" {
		err = errors.New("`gocd.Jobs.Name` is empty")
	}
	return
}

func (tf *TimeoutField) UnmarshalJSON(b []byte) (err error) {
	value := string(b)
	var valInt int

	if value == `"never"` || value == "null" {
		valInt = 0
	} else {
		valInt, err = strconv.Atoi(value)
	}
	valTf := TimeoutField(valInt)
	tf = &valTf

	return
}

func (tf TimeoutField) MarshalJSON() (b []byte, err error) {
	return []byte(strconv.Itoa(int(tf))), nil
}
{'fraction_non_alphanumeric': 0.15261044176706828, 'fraction_numerical': 0.0011474469305794606, 'mean_word_length': 3.613756613756614, 'pattern_counts': {'":': 0, '<': 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': '2058741', 'n_tokens_mistral': 687, 'n_tokens_neox': 670, 'n_words': 198}