--- title: "toJSON" slug: "calc-function-to-json" updated: 2026-02-17T09:38:49Z published: 2026-02-17T09:38:49Z canonical: "docs.lobstersoftware.com/calc-function-to-json" --- > ## Documentation Index > Fetch the complete documentation index at: https://docs.lobstersoftware.com/llms.txt > Use this file to discover all available pages before exploring further. # toJSON > [!NOTE] > Serialisiert ein Objekt in die enstprechende JSON Darstellung. > > > [!TIP] > > Tooltip > > > > Syntax: *$toJSON(object[,format=false[,classField=class]])* > > > > | Parameter | Beschreibung | > > | --- | --- | > > | `object` | Das zu serialisierende Objekt | > > | `format` | Optional, Standardwert = false, true um ein formatiertes JSON zu erzeugen | > > | `classField` | Optional, Standardwert = "class", gibt an in welcher Property nach dem Klassennamen gesucht werden soll. Dies muss ggf. auf clazz gestellt werden. | > > | `forceNativeTypes` | Optional, Standardwert = false, true um native JSON Typen zu erzwingen, z.B. (Long wird als JSON Zahl geschrieben, Liste wird als Array geschrieben) | > > > > Gibt das Objekt als JSON String zurück. > > > > Beispiel: $toJSON($el(5)) *Siehe auch* [parseJSON](/v1/docs/calc-function-parse-json) ## Syntax *$toJSON(object[,format=false[,classField=class]])* ## Parameter | Name | Beschreibung | | --- | --- | | object | Das zu serialisierende Objekt | | format | Optional, Standardwert = false, true um ein formatiertes JSON zu erzeugen | | *classField* | Optional, Standardwert = "class", gibt an in welcher Property nach dem Klassennamen gesucht werden soll. Dies muss ggf. auf clazz gestellt werden. | ## Rückgabewert Das Objekt als JSON Beispiel | Syntax | Ergebnis | | --- | --- | | $toJSON($el(12)) | "Element12SimpleText" | | $toJSON($el(11)) | ```json {"el12":"Element12SimpleText"} ``` | | $toJSON($el(11),$true) | ```json { "el12": "Element12SimpleText" } ``` |