<commit_before>package tinyjson

import (
	"encoding/json"
	"net/http"
	"strconv"
)

func Write(w http.ResponseWriter, v interface{}) {
	payload, err := json.Marshal(v)
	if err != nil {
		http.Error(w, err.Error(), http.StatusInternalServerError)
	}
	w.Header().Set("Content-Type", "application/json")
	w.Header().Set("Content-Length", strconv.Itoa(len(content)))
	w.Write(payload)
}

func Read(r *http.Request, v interface{}) error {

}<commit_msg>[add] read function, need tests<commit_after>package tinyjson

import (
	"encoding/json"
	"net/http"
	"strconv"
)

func Write(w http.ResponseWriter, v interface{}) {
	payload, err := json.Marshal(v)
	if err != nil {
		http.Error(w, err.Error(), http.StatusInternalServerError)
	}
	w.Header().Set("Content-Type", "application/json")
	w.Header().Set("Content-Length", strconv.Itoa(len(content)))
	w.Write(payload)
}

// a handy one-liner to sugar up receiving JSON POST requests
func Read(r *http.Request, v interface{}) error {
	return json.NewDecoder(r.Body).Decode(&v)
}
{'fraction_non_alphanumeric': 0.17058823529411765, 'fraction_numerical': 0.0, 'mean_word_length': 5.0773809523809526, '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': '5332441', 'n_tokens_mistral': 365, 'n_tokens_neox': 358, 'n_words': 78}