Skip to content

How to catch JSON parse errors? #225

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

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions