---
title: "JSValueCreateJSONString(_:_:_:_:)"
framework: javascriptcore
role: symbol
role_heading: Function
path: "javascriptcore/jsvaluecreatejsonstring(_:_:_:_:)"
---

# JSValueCreateJSONString(_:_:_:_:)

Creates a JavaScript string that contains the JSON-serialized representation of a JavaScript value.

## Declaration

```swift
func JSValueCreateJSONString(_ ctx: JSContextRef!, _ value: JSValueRef!, _ indent: UInt32, _ exception: UnsafeMutablePointer<JSValueRef?>!) -> JSStringRef!
```

## Parameters

- `ctx`: The execution context to use.
- `value`: The value to serialize.
- `indent`: The number of spaces to indent when nesting. If 0, the resulting JSON string doesn’t contain new lines. The size of the indent clamps to 10 spaces.
- `exception`: A pointer to a doc://com.apple.javascriptcore/documentation/JavaScriptCore/JSValueRef to store an exception in, if any. Pass NULL to discard any exception.

## Return Value

Return Value A JSStringRef with the result of serialization, or NULL if the system throws an exception.

## See Also

### Converting to and from JSON-Formatted Strings

- [JSValueMakeFromJSONString(_:_:)](javascriptcore/jsvaluemakefromjsonstring(_:_:).md)
