sm.json

Parses and writes json files from and to lua values.

Functions:

  • fileExists
  • open
  • parseJsonString
  • save
  • writeJsonString

  • sm.json.fileExists(path)

    Checks if a json file exists at the input path

    Parameters:

    TypeNameDescription
    stringpathThe json file path.

    Returns:

    TypeDescription
    booleanReturn true if the file exists.

    sm.json.open(path)

    Opens a json file and parses to Lua table.

    Parameters:

    TypeNameDescription
    stringpathThe json file path.

    Returns:

    TypeDescription
    tableThe table.

    sm.json.parseJsonString(json)

    Parses a json string to lua table.

    Parameters:

    TypeNameDescription
    stringjsonThe json string.

    Returns:

    TypeDescription
    tableThe table.

    sm.json.save(root, path)

    Write a lua table to json.

    Parameters:

    TypeNameDescription
    tablerootThe lua table.
    stringpathThe json file path.

    sm.json.writeJsonString(root)

    Writes a json string from a lua table.

    Parameters:

    TypeNameDescription
    stringrootThe lua table.

    Returns:

    TypeDescription
    stringThe json string.