Skip to content

Instantly share code, notes, and snippets.

View AlienHoboken's full-sized avatar

Jeremiah AlienHoboken

  • United States of America
View GitHub Profile
@AlienHoboken
AlienHoboken / valve-data-format-jsonify.php
Last active October 14, 2021 15:31
This short PHP script will create valid JSON data from Valve Data Format (VDF) data, such as items_game.txt files for TF2 and DotA 2. This allows for much greater ease in parsing the data it contains.
<?php
//load VDF data either from API call or fetching from file/url
//no matter your method, $json must contain the VDF data to be parsed
$json = file_get_contents("items_game.txt");
//encapsulate in braces
$json = "{\n$json\n}";
//replace open braces
$pattern = '/"([^"]*)"(\s*){/';