---
title: sto_from_json
description: Format JSON as an STO object (binary encoded ledger data).
---
import { Tabs, TabItem, LinkButton } from '@astrojs/starlight/components';

### Concepts

<LinkButton href="/docs/hooks/concepts/serialized-objects">Serialized Objects</LinkButton>

### Behaviour

<Tabs>
<TabItem label="JavaScript">
* Takes a JSON object and converts it into a binary encoded ledger data format.
* Returns STO Object in binary encoded ledger data format, or an error code if the conversion fails.
</TabItem>
</Tabs>



### Definition

<Tabs>
<TabItem label="JavaScript">
```javascript
function sto_from_json(
    jsonobj: Record<string, any> | Transaction
  ): ErrorCode | ByteArray
```
</TabItem>
</Tabs>



### Example

<Tabs>
<TabItem label="JavaScript">
```javascript
const stoBlob = sto_from_json(stoJson)
```
</TabItem>
</Tabs>



### Parameters

<Tabs>
<TabItem label="JavaScript">


| Name    | Type                                | Description                                     |
| ------- | ----------------------------------- | ----------------------------------------------- |
| jsonobj | Record\<string, any> \| Transaction | JSON object to be converted into an STO object. |
</TabItem>
</Tabs>



### Return Code

<Tabs>
<TabItem label="JavaScript">


| Type                   | Description                                                                                |
| ---------------------- | ------------------------------------------------------------------------------------------ |
| ErrorCode \| ByteArray | STO Object in binary encoded ledger data format, or an error code if the conversion fails. |
</TabItem>
</Tabs>

