refactor: Switch formula format from YAML to JSON

- Change file extension from .formula.yaml to .formula.json
- Replace gopkg.in/yaml.v3 with encoding/json in parser
- Remove yaml struct tags, keep json tags only
- Update all test cases to use JSON format
- Update documentation references

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Steve Yegge
2025-12-25 01:37:10 -08:00
parent a8ec1d6483
commit e6ce0d6365
6 changed files with 158 additions and 166 deletions

View File

@@ -1,17 +1,16 @@
package formula
import (
"encoding/json"
"fmt"
"os"
"path/filepath"
"regexp"
"strings"
"gopkg.in/yaml.v3"
)
// FormulaExt is the file extension for formula files.
const FormulaExt = ".formula.yaml"
const FormulaExt = ".formula.json"
// Parser handles loading and resolving formulas.
//
@@ -97,11 +96,11 @@ func (p *Parser) ParseFile(path string) (*Formula, error) {
return formula, nil
}
// Parse parses a formula from YAML bytes.
// Parse parses a formula from JSON bytes.
func (p *Parser) Parse(data []byte) (*Formula, error) {
var formula Formula
if err := yaml.Unmarshal(data, &formula); err != nil {
return nil, fmt.Errorf("yaml: %w", err)
if err := json.Unmarshal(data, &formula); err != nil {
return nil, fmt.Errorf("json: %w", err)
}
// Set defaults