Skip to content

nosoop/vdf-json-java

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

28 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

vdf-json-java

Class to convert Valve Data Format / Source Engine KeyValue format files to JSON format. All values are either strings or nested KeyValues.

Supported are nested KeyValues, parsing out C++ comments, converting a set of KeyValues "0" ... "n" to a JSONArray. Currently unsupported are imports and resolving numbers to boolean / integer values, but otherwise the conversion's pretty good.

The parsing is lazy; you can feed it a partial file and you'll still get some JSON data. Might not want that, but oh well.

Single source file for it.

Depends on the org.json library.

Released under the MIT license.

Sample conversion results

// Snippet of Original JSON
// Source: http://api.steampowered.com/ISteamWebAPIUtil/GetSupportedAPIList/v0001/?format=json
{"apilist": {"interfaces": [
    {
        "methods": [{
            "name": "GetServerVersion",
            "httpmethod": "GET",
            "parameters": [],
            "version": 1
        }],
        "name": "IGCVersion_205790"
    },
    {
        "methods": [
            {
                "name": "GetServerInfo",
                "httpmethod": "GET",
                "parameters": [],
                "version": 1
            },
            {
                "name": "GetSupportedAPIList",
                "httpmethod": "GET",
                "parameters": [{
                    "description": "access key",
                    "optional": true,
                    "name": "key",
                    "type": "string"
                }],
                "version": 1
            }
        ],
        "name": "ISteamWebAPIUtil"
    }]
}}

// Snippet of converted VDF data with array conversion enabled.
// Source: http://api.steampowered.com/ISteamWebAPIUtil/GetSupportedAPIList/v0001/?format=vdf
{"apilist": {"interfaces": [
    {
        "methods": [{
            "name": "GetServerVersion",
            "httpmethod": "GET",
            "parameters": [],
            "version": "1"
        }],
        "name": "IGCVersion_205790"
    },
    {
        "methods": [
            {
                "name": "GetServerInfo",
                "httpmethod": "GET",
                "parameters": [],
                "version": "1"
            },
            {
                "name": "GetSupportedAPIList",
                "httpmethod": "GET",
                "parameters": [{
                    "description": "access key",
                    "name": "key",
                    "optional": "1",
                    "type": "string"
                }],
                "version": "1"
            }
        ],
        "name": "ISteamWebAPIUtil"
    }]
}}

About

Class to convert Valve Data Format files to JSON format

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages