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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user