# CborToJson()

Converts CBOR (Concise Binary Object Representation) binary data directly to a JSON string, without going through CFML types first. Useful when you receive CBOR from an external system and need to pass it on as JSON — for example, logging or forwarding WebAuthn attestation data to a JSON API.

**Requires Extension:** [Crypto Extension](https://download.lucee.org/#17AB52DE-B300-A94B-E058FC978BE4542D)

```
CborToJson( data=any );
```

**Returns:** string

# Arguments

| Argument | Type | Required | Description | Default |
|----------|------|----------|-------------|---------|
| data | any | Yes | CBOR-encoded binary data |  |

# Usage Notes

This converts directly from CBOR to JSON using the underlying library — it does not go through CFML types, avoiding the intermediate conversion step of `serializeJSON( CborDecode( cbor ) )`.

**Binary data:** CBOR byte strings are base64-encoded in the JSON output, since JSON has no native binary type.

**Integer keys:** CBOR integer keys (like those in COSE maps) are converted to JSON string keys, since JSON only supports string keys.

# Examples

```cfml
// Convert CBOR binary data directly to a JSON string
// A more direct alternative to serializeJSON( CborDecode( cbor ) )

cbor = CborEncode( { name: "test", value: 42 } );
json = CborToJson( cbor );
// json is a valid JSON string: {"name":"test","value":42}

// Convert a CBOR array to JSON
cbor = CborEncode( [ 1, "two", 3 ] );
json = CborToJson( cbor );
// [1,"two",3]

// Practical use: log WebAuthn attestation data as JSON for debugging
attestationCbor = Base64UrlDecode( response.attestationObject );
echo( CborToJson( attestationCbor ) );
```







# Categories

[Cryptography](../../categories/crypto.md)

# See Also

[CborDecode()](cbordecode.md), [JsonToCbor()](jsontocbor.md)