A Lexer and Parser for Valves Data Format (known as vdf) written in Go.
It is go gettable
$ go get github.com/andygrunwald/vdf
(optional) to run unit / example tests:
$ cd $GOPATH/src/github.com/andygrunwald/vdf
$ go test -v ./...
Given a file named example.vdf
with content:
"Example"
{
"TimeNextStatsReport" "1234567890"
"ContentStatsID" "-7123456789012345678"
}
Can be parsed with this Go code:
package main
import (
"fmt"
"github.com/andygrunwald/vdf"
"log"
"os"
)
func main() {
f, err := os.Open("./example.vdf")
if err != nil {
log.Fatal(err)
}
p := vdf.NewParser(f)
m, err := p.Parse()
if err != nil {
log.Fatal(err)
}
fmt.Println(m)
}
And it will output:
map[
Example:map[
TimeNextStatsReport:1234567890
ContentStatsID:-7123456789012345678
]
]
The code and project idea is heavily inspired and driven by @benbjohnson article Handwritten Parsers & Lexers in Go and his example sql-parser. Thank you Ben!
- PHP and JavaScript: rossengeorgiev/vdf-parser
- PHP: https://github.com/devinwl/keyvalues-php
- PHP: lukezbihlyj/vdf-parser
- C#: sanmadjack/VDF
- Java: DHager/hl2parse
- And many more: Github search for vdf valve
This project is released under the terms of the MIT license.