Skip to content

How to catch JSON parse errors? #225

Open
@trieloff

Description

@trieloff

Is there a way to verify that a given input is indeed valid JSON?

I'm able to guard against the parsed value not being the object I expect, but not against it not being JSON at all:

let body = <JSON.Value>JSON.parse(text);
  if (body != null && body.isObj) {

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requested

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions