# JSON in 1C:Enterprise: read, write, HTTP requests and common errors

Source: https://checkcraft.ru/en/guides/1c-json.html · updated 2026-11-24

How to read JSON into a Structure or Map in 1C, write a Structure to a JSON string or file, send a POST with a JSON body via HTTPConnection, and avoid BOM…

Practical workflow

Checkcraft is a desktop app for checking APIs and logs without code, with a free edition. [Download, no sign-up →](https://checkcraft.ru/en/download-checkcraft.html#free-download)

In 1C:Enterprise 8.3 JSON is read with the JSONReader object and the ReadJSON function and written with JSONWriter and WriteJSON. Below are working samples: string to Structure, Structure to string, files, an HTTP request with a JSON body, dates and the usual integration errors.

Checkcraft · 24 November 2026

Get help with your first test →

## How to read JSON in 1C

Create a JSONReader, give it a string with SetString or a file with OpenFile, and call ReadJSON. The second parameter decides the result: False gives a Structure, True gives a Map. A Map is safer, because JSON keys such as order-id or 1st cannot be Structure property names.

## How to write JSON in 1C

Create a JSONWriter, call SetString for a string or OpenFile for a file, then WriteJSON with the value and Close. Close returns the ready string. You can write a Structure, a Map with string keys, an Array, strings, numbers, booleans and Undefined, which becomes null.

Repeating checks like this by hand? Checkcraft saves them and reruns them in one click. [Download Free →](https://checkcraft.ru/en/download-checkcraft.html#free-download)

## How to send JSON in an HTTP request

Build the string with JSONWriter, create an HTTPRequest with the resource path, add the Content-Type: application/json header and set the body with SetBodyFromString in UTF-8 without a BOM. POST is sent with Post, other methods with CallHTTPMethod. Check the status code and content type before reading the JSON.

## Why another system rejects JSON from 1C

Usually one of three things: a BOM at the start of the body, dates in a format the other side does not expect, and numbers written as strings. Compare what you sent with the partner's documented example. A JSON validator and a simple JSON diff are the fastest way.

## How to check a JSON exchange regularly

A one-off check in the debugger guarantees nothing for the next release. Save the request to the HTTP service or partner together with rules: status code, required fields, totals, no errors in the exchange log. After each configuration update the check repeats with one click.

## Example: JSON string to Map

```
ЧтениеJSON = Новый ЧтениеJSON;
ЧтениеJSON.УстановитьСтроку(СтрокаJSON);
Данные = ПрочитатьJSON(ЧтениеJSON, Истина); // Истина: Соответствие, Ложь: Структура
ЧтениеJSON.Закрыть();

Итог = Данные.Получить("total");
Для Каждого Позиция Из Данные.Получить("items") Цикл
    Сообщить(Позиция.Получить("sku"));
КонецЦикла;
```

Reading into a Structure (second parameter False) lets you use dot access, but any key with a dash, space or leading digit breaks reading. For other services' responses use a Map.

## Example: Structure to JSON string

```
Заказ = Новый Структура;
Заказ.Вставить("id", 5001);
Заказ.Вставить("status", "NEW");
Позиции = Новый Массив;
Позиция = Новый Структура("sku, qty", "A-1", 2);
Позиции.Добавить(Позиция);
Заказ.Вставить("items", Позиции);

ЗаписьJSON = Новый ЗаписьJSON;
ЗаписьJSON.УстановитьСтроку(Новый ПараметрыЗаписиJSON(ПереносСтрокJSON.Нет));
ЗаписатьJSON(ЗаписьJSON, Заказ);
СтрокаJSON = ЗаписьJSON.Закрыть(); // {"id":5001,"status":"NEW","items":[{"sku":"A-1","qty":2}]}
```

ПереносСтрокJSON.Нет (no line breaks) gives a compact string for sending. For logs and debugging ПереносСтрокJSON.Авто indents the JSON.

## Reading and writing a JSON file

```
// запись в файл
ЗаписьJSON = Новый ЗаписьJSON;
ЗаписьJSON.ОткрытьФайл("C:\Обмен\order.json", "UTF-8");
ЗаписатьJSON(ЗаписьJSON, Заказ);
ЗаписьJSON.Закрыть();

// чтение из файла
ЧтениеJSON = Новый ЧтениеJSON;
ЧтениеJSON.ОткрытьФайл("C:\Обмен\order.json");
Данные = ПрочитатьJSON(ЧтениеJSON, Истина);
ЧтениеJSON.Закрыть();
```

## POST with JSON via HTTPConnection

```
Соединение = Новый HTTPСоединение("api.example.com", 443, , , , 30, Новый ЗащищенноеСоединениеOpenSSL);
Запрос = Новый HTTPЗапрос("/api/orders");
Запрос.Заголовки.Вставить("Content-Type", "application/json");
Запрос.Заголовки.Вставить("Authorization", "Bearer " + Токен);
Запрос.УстановитьТелоИзСтроки(СтрокаJSON, "UTF-8", ИспользованиеByteOrderMark.НеИспользовать);

Ответ = Соединение.ОтправитьДляОбработки(Запрос); // POST
ТипОтвета = Ответ.Заголовки.Получить("Content-Type");
ТелоОтвета = Ответ.ПолучитьТелоКакСтроку("UTF-8");

Если Ответ.КодСостояния <> 201 Тогда
    ВызватьИсключение СтрШаблон("Код %1, тело: %2", Ответ.КодСостояния, Лев(ТелоОтвета, 200));
КонецЕсли;
```

Set the third parameter of SetBodyFromString explicitly. A BOM at the start of the body is a common reason a partner service answers 400 or cannot parse the request. To see exactly what is sent, repeat the request with curl, see [curl POST with JSON](https://checkcraft.ru/en/guides/curl-post-json.html).

## Dates in JSON and 1C

```
// чтение: поля created и paidAt превратятся в Дату
Данные = ПрочитатьJSON(ЧтениеJSON, Истина, "created,paidAt", ФорматДатыJSON.ISO);

// запись: даты в ISO 8601
Настройки = Новый НастройкиСериализацииJSON;
Настройки.ФорматСериализацииДаты = ФорматДатыJSON.ISO;
ЗаписатьJSON(ЗаписьJSON, Заказ, Настройки);
```

Without the property names dates stay strings. If the partner sends times with a time zone, agree which zone to store, or a three-hour shift will show up in reports.

## JSON and 1C types

| JSON | Read in 1C as | Mind |
|---|---|---|
| object {} | Structure or Map | Map for keys with dashes or digits |
| array [] | Array | Order is kept |
| string | String | A date stays a string unless listed |
| number | Number | Money comes as a fraction, round explicitly |
| true, false | Boolean | The string "true" is not a boolean |
| null | Undefined | Tell it apart from a missing key |

## Checking a 1C JSON exchange from outside

1. Send a request to the 1C HTTP service (a /hs/... path) with curl or an API client and look at status, headers and body.
2. Compare the response with the contract: required fields, types, totals.
3. Check that a partner error comes as clear JSON, not an HTML page.
4. Save these checks and repeat them after every configuration update.

If the response does not parse, start with [unexpected character when reading JSON](https://checkcraft.ru/en/guides/1c-json-unexpected-character.html).

## More on 1C

Section overview and all guides: [1C integration via API: options, architecture and examples](https://checkcraft.ru/en/guides/1c-api-integration.html).

- [Unexpected character when reading JSON in 1C: causes and fixes](https://checkcraft.ru/en/guides/1c-json-unexpected-character.html)
- [Structure, Array and ValueTable to JSON in 1C: both directions](https://checkcraft.ru/en/guides/1c-json-value-table.html)
- [Data exchange in 1C: methods, formats, setup and checks](https://checkcraft.ru/en/guides/1c-data-exchange.html)
- [Integrating 1C with a website and online store: options and pitfalls](https://checkcraft.ru/en/guides/1c-site-integration.html)
- [Automated testing in 1C: Vanessa Automation, YAxUnit and integration checks](https://checkcraft.ru/en/guides/1c-automated-testing.html)

Next step

## Repeat this on your own API

Checkcraft is a desktop app that saves API response checks without code and shows what did not match. Start with a sample, then use your own sanitized data. Free runs on Windows and Linux with no time limit.

[Download Free](https://checkcraft.ru/en/download-checkcraft.html#free-download) · [Download and first run](https://checkcraft.ru/en/download-checkcraft.html)

No sign-up or email needed, the archive is ready in a couple of minutes. See the [edition limits](https://checkcraft.ru/en/pricing.html).

## References

[RFC 8259: the JSON format](https://www.rfc-editor.org/rfc/rfc8259) · [1C:ITS — development standards](https://its.1c.ru/db/v8std)

## Continue with a related task

[Unexpected character when reading JSON in 1C: causes and fixes](https://checkcraft.ru/en/guides/1c-json-unexpected-character.html) · [Unexpected token <, <!DOCTYPE is not valid JSON: the server returned HTML](https://checkcraft.ru/en/guides/json-doctype-not-valid.html) · [Online JSON validator that explains the error](https://checkcraft.ru/en/guides/json-validator-online.html) · [Compare two JSON documents online: added, missing and changed](https://checkcraft.ru/en/guides/json-compare-online.html) · [cURL examples: GET and POST requests with JSON on Linux, Windows and PowerShell](https://checkcraft.ru/en/guides/curl-post-json.html) · [Create XML response tests without code](https://checkcraft.ru/en/guides/xml-autotests-without-code.html)

Start with the linked example and compare its result with your own test requirement.

Ask a person

## Get help with your first test

Tell us what you want to test or where you got stuck. We can help you start Checkcraft, choose an example and understand your first run. You can ask before downloading.

[Ask in Telegram](https://t.me/checkcraftchat)Send an email

The Telegram group is public: do not post passwords, tokens or confidential work data. A description of your task is enough to start.

You can also email us support@checkcraft.ru

Page card: /ai/pages/en/guides/1c-json.md
