fivem-ts

a library to speed up the development of Fivem scripts and frameworks


Project maintained by Purpose-Dev Hosted on GitHub Pages — Theme by mattgraham

fivem-ts - Documentation v0.7.5Docs


fivem-ts - Documentation v0.7.5 / Shared / serializeToJSON

Function: serializeToJSON()

serializeToJSON(data): string

Serializes a value to a JSON string.

This function takes any value, such as objects, arrays, numbers, strings, etc., and converts it into a JSON-formatted string. This is useful for storing or transmitting data in a format that is widely supported and can be easily parsed by other systems.

Parameters

data: unknown

The value to be serialized to JSON. This can be an object, array, string, number, etc.

Returns

string

A JSON string representing the serialized data.

Example

const obj = { name: "John", age: 30 };
const jsonString = serializeToJSON(obj);
console.log(jsonString); // Output: '{"name":"John","age":30}'

Defined in

shared/utils/serializeToJSON.ts:19