Options
All
  • Public
  • Public/Protected
  • All
Menu

Module json

Type aliases

JsonPrimitiveType

JsonPrimitiveType: boolean | null | number | string

JsonType

JSON Basic Functions

jsonJsonify

  • jsonJsonify(value: any, defaultResult?: any, unsafe?: boolean, fix?: boolean): JsonType
  • name

    jsonJsonify

    description

    Attempts to convert any value to JSON allowed value.

    summary

    import { jsonJsonify } from "@corefunc/corefunc/json/basic/jsonify";

    since

    0.0.87

    example

    jsonJsonify({ 1: "one" }) ➜ {"1":"one"}

    Parameters

    • value: any
    • Optional defaultResult: any
    • unsafe: boolean = true
    • fix: boolean = true

    Returns JsonType

    Plain value or plain object.

JSON Parse Functions

jsonParseAttempt

  • jsonParseAttempt<T>(value: T): T
  • name

    jsonParseAttempt

    description

    Trying parse value and if fails return original value.

    summary

    import { jsonParseAttempt } from "@corefunc/corefunc/json/parse/attempt";

    since

    0.2.2

    Type parameters

    • T

    Parameters

    • value: T

    Returns T

    Parsed value or original value.

jsonParseSafe

  • jsonParseSafe(text: string, defaultResult?: any, unsafe?: boolean, fix?: boolean, reviver?: function): any
  • Parameters

    • text: string
    • Optional defaultResult: any
    • unsafe: boolean = true
    • fix: boolean = true
    • Optional reviver: function
        • (this: any, key: string, value: any): any
        • Parameters

          • this: any
          • key: string
          • value: any

          Returns any

    Returns any

Other Functions

jsonCleanup

  • jsonCleanup(text: string): string
  • Parameters

    • text: string

    Returns string

jsonParseDeep

  • jsonParseDeep(text: string, defaultResult?: any, reviver?: function): any
  • Parameters

    • text: string
    • Optional defaultResult: any
    • Optional reviver: function
        • (this: any, key: string, value: any): any
        • Parameters

          • this: any
          • key: string
          • value: any

          Returns any

    Returns any

jsonParseStringify

  • jsonParseStringify(text: string): string
  • Parameters

    • text: string

    Returns string

jsonParseUnsafe

  • jsonParseUnsafe(text: string, defaultResult?: any): any
  • Parameters

    • text: string
    • Optional defaultResult: any

    Returns any

jsonParseWith

  • jsonParseWith(text: string, defaultResult?: any, unsafe?: boolean, reviver?: function): any
  • Parameters

    • text: string
    • Optional defaultResult: any
    • unsafe: boolean = true
    • Optional reviver: function
        • (this: any, key: string, value: any): any
        • Parameters

          • this: any
          • key: string
          • value: any

          Returns any

    Returns any

Generated using TypeDoc