vdf icon indicating copy to clipboard operation
vdf copied to clipboard

String-only parsing mode

Open LONGACAT opened this issue 3 years ago • 1 comments

Add an optional parameter to the parse function which makes the returned object contain only strings.

Use case - parsing an appmanifest.acf, some of the values lose precision if they're numbers. The file contains: "manifest" "5024399731943401779" Parsing it will return: manifest: 5024399731943401000 A part of the value is lost. After removing the code which was responsible for converting the types, it's correctly parsed as: manifest: '5024399731943401779'

Responsible code:

if (val !== '' && !isNaN(val)) val = +val;
if (val === 'true')            val = true;
if (val === 'false')           val = false;
if (val === 'null')            val = null;
if (val === 'undefined')       val = undefined;

LONGACAT avatar Jul 21 '21 21:07 LONGACAT