Skip to content

Integer is not Num, only Float is #305

Open
@evaporei

Description

@evaporei
let jsonObj: JSON.Obj = <JSON.Obj>(JSON.parse('{"value": 24}'));
let value: JSON.Value = jsonObj.getValue("value")!;

assert(!value.isNum)
assert(value.isInteger)

jsonObj = <JSON.Obj>(JSON.parse('{"value": 4.2}'));
value = jsonObj.getValue("value")!;

assert(value.isNum)
assert(value.isFloat)

This happens because only Float extends Num, Integer doesn't extend it.

I'm only pointing this out because the README.md's example is incorrect, since the JSON parsed in it has an Integer and not a Num:

{"hello": "world", "value": 24}

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