Skip to content

String-only parsing mode #10

@LONGACAT

Description

@LONGACAT

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;

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions