<commit_before>package jsh

import (
	"encoding/json"
	"fmt"
	"io"
	"io/ioutil"
	"log"
)

const (
	// ContentType is the data encoding of choice for HTTP Request and Response Headers
	ContentType = "application/vnd.api+json"
)

// ParseObject returns a JSON object for a given io.ReadCloser containing
// a raw JSON payload
func ParseObject(reader io.ReadCloser) (*Object, SendableError) {
	defer closeReader(reader)

	byteData, err := ioutil.ReadAll(reader)
	if err != nil {
		return nil, ISE(fmt.Sprintf("Error attempting to read request body: %s", err))
	}

	data := struct {
		Object Object `json:"data"`
	}{}

	err = json.Unmarshal(byteData, &data)
	if err != nil {
		return nil, ISE(fmt.Sprintf("Unable to parse json: \n%s\nError:%s",
			string(byteData),
			err.Error(),
		))
	}

	object := &data.Object
	return object, validateInput(object)<commit_msg>Big parse object example<commit_after>package jsh

import (
	"encoding/json"
	"fmt"
	"io"
	"io/ioutil"
	"log"
)

const (
	// ContentType is the data encoding of choice for HTTP Request and Response Headers
	ContentType = "application/vnd.api+json"
)

// ParseObject returns a JSON object for a given io.ReadCloser containing
// a raw JSON payload
//
//	func Handler(w http.ResponseWriter, r *http.Request) {
//		obj, error := jsh.ParseObject(r.Body)
//		if error != nil {
//			// log your error
//			jsh.Send(r, w, error)
//			return
//		}
//
//		yourType := &YourType
//
//		err := object.Unmarshal("yourtype", &YourType)
//		if err != nil {
//			jsh.Send(r, w, err)
//			return
//		}
//
//		yourType.ID = obj.ID
//		// do business logic
//
//		response, err := jsh.NewObject(yourType.ID, "yourtype", &yourType)
//		if err != nil {
//			// log error
//			jsh.Send(r, w, err)
//			return
//		}
//
//		err := jsh.Send(r, w, response)
//		if err != nil {
//			http.Error(w, err.Status, err.Detail)
//		}
//	}
func ParseObject(reader io.ReadCloser) (*Object, SendableError) {
	defer closeReader(reader)

	byteData, err := ioutil.ReadAll(reader)
	if err != nil {
		return nil, ISE(fmt.Sprintf("Error attempting to read request body: %s", err))
	}

	data := struct {
		Object Object `json:"data"`
	}{}

	err = json.Unmarshal(byteData, &data)
	if err != nil {
		return nil, ISE(fmt.Sprintf("Unable to parse json: \n%s\nError:%s",
			string(byteData),
			err.Error(),
		))
	}

	object := &data.Object
	return object, validateInput(object)
{'fraction_non_alphanumeric': 0.1601840234211627, 'fraction_numerical': 0.0, 'mean_word_length': 3.203866432337434, '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': '5333604', 'n_tokens_mistral': 920, 'n_tokens_neox': 879, 'n_words': 233}