An open API service indexing awesome lists of open source software.

https://github.com/qwreey/vdf-lua

This is a Lua implementation of [KeyValues](https://developer.valvesoftware.com/wiki/KeyValues) from valvesoftware.
https://github.com/qwreey/vdf-lua

Last synced: 11 months ago
JSON representation

This is a Lua implementation of [KeyValues](https://developer.valvesoftware.com/wiki/KeyValues) from valvesoftware.

Awesome Lists containing this project

README

          

# vdf.lua

This is a Lua implementation of [KeyValues](https://developer.valvesoftware.com/wiki/KeyValues) from valvesoftware.

#include and #base are not supported, this is just basic implementation. (due to lua's filesystem libs are differ for every engines)

# usages

## parse(str:string)

parsing VDF string into lua table structure

Preview:
```lua
local vdf = require("vdf")
local data = vdf.parse([[
"a"
{
"key" "value"
}
]])
print(data.a.key) -- prints 'value'
```

## stringify(data:table,indent:string?,disableNewline:boolean?)

### param1 data:table

lua table structure which should converted into VDF format

### param2 indent:string? (default: " ")

An indent-based string that is repeated based on its depth.
If you don't want to indent, provide a false

## pram3 disableNewline:boolean?

By default, stringify uses newlines, but if you don't want to, you can disable them by providing true

Preview:
```lua
local vdf = require("vdf")
local data = { item = { value = "5000", element = "true" } }
print(vdf.stringify(data))
--[[
it prints

"item"
{
"value" "5000"
"element" "true"
}
]]
```