Giter VIP home page Giter VIP logo

vdf's Introduction

vdf

A Parser for Valves Data Format (known as vdf) written in Go. Comments are not preserved during parsing.

Installation

It is go gettable

$ go get github.com/perplex/vdf

Usage

The parser will return a KeyValue type that can handle querying for submaps, objects, and values without the need to worry about type assertions.

firstkey
{
	secondkey
	{
		"attr1" "val1"
		"attr2" "val2"
	}
}

In the above example firstkey would be a submap as it is of the type map[string]interface{}, while secondkey can either be a submap or an object. An object is defined as a map[string]string, so it is the final map structure before looping over values. Val1 and val2 are both values as there is no map structure below them. Querying for secondkey as a submap would look like this

package main

import (
	"fmt"
	"github.com/perplex/vdf"
)

func main() {

	obj, err := vdf.ParseFile("path/to/example.vdf", false)
	if err != nil {
		panic(err)
	}
	
	sm, err := obj.GetSubmap("firstkey", "secondkey")
	if err != nil {
		panic(err)
	}
	
	fmt.Println(sm.GetKeys())
}

This would print attr1 and attr2.

Inspiration

This is based on the original fork of this repo from andygrunwald and simple-vdf.

vdf's People

Contributors

andygrunwald avatar perplex avatar step7750 avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

step7750

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.