Account for duplicate keys in VDF to JSON transformation #7
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Valve's VDF format is pretty freeform - duplicate keys are permissible. Unfortunately it is hard to distinguish between errors and intentional duplicate keys. For most VDFs, duplicate keys appear to be errors (certain keys are specified more than once with the same value). However, in
items_game.txt
duplicate keys appear to serve a purpose. This PR allows us to specify specific files where duplicate keys are allowed, and transform the VDFs to JSON accordingly. More details below.While it would be best to have this behaviour (allow duplicate keys) by default for all conversions, I am conscious not to break any projects currently using these files. This is tricker with the fact that not all keys in all objects are consistently arrays, so code will need to be updated to support the fact that any key could have multiple values represented as an array, or a singular value represented without an array.
As a result, only
items_game.json
will be affected by this change for now, which is described below:This PR also adds a command line arugment to
update.rb
. This allows someone to run the update script without extracting the VPK and only runs the VDF > JSON generation step. This requires that the VDF's already exist in the corresponding paths (they are checked into this repo).To regenerate the JSON files, simply run
ruby update.rb --skip-vpk
.