View a markdown version of this page

Writing rows in JSON - Amazon Simple Storage Service

Writing rows in JSON

To send JSON, set x-amz-payload-format to JSON.

Formatting a JSON payload

Send the rows as newline-delimited JSON (NDJSON):

  • Encode the payload as UTF-8, without a byte order mark.

  • Write one JSON object per line, and separate rows with a line feed (\n). PutRows doesn't accept a carriage return (\r\n or \r) as a line delimiter.

  • Send at least one row. The payload can end with one line feed, but can't contain blank lines.

  • Don't add whitespace at the start or end of a row. Whitespace is allowed between tokens, but not necessary.

  • Use standard JSON (RFC 8259). PutRows doesn't accept JSON extensions, such as comments, trailing commas, single quotes, or a bare NaN.

The following example payload contains two rows.

{"id": 1, "name": "Alice", "signup": "2026-01-15"} {"id": 2, "name": "Bob", "signup": "2026-02-03"}

Mapping JSON keys to columns

Each row is a JSON object that corresponds to the top level of the table's schema, so each top-level key names a column. Inside a struct value, each key names a field of that struct. PutRows matches keys by exact name, so a period (.) in a key is part of the field name, not a path in the schema.

Column names can contain Unicode characters. A key can use the escape sequences that RFC 8259 defines, such as a Unicode escape for a character like é, and must escape control characters, as in any JSON string.

If a row sets the same column more than once, for example by repeating a key, PutRows rejects the request.

JSON data types

The following table shows how to write a value for each Iceberg column type.

JSON values for Iceberg column types
Iceberg type JSON value Example
boolean true or false, or the strings "true" or "false" true
int, long An integer, as a number or a string 42, "42"
float, double A number or a string, or one of the strings "NaN", "Infinity", or "-Infinity" 1.5, 6.02E23, "NaN"
decimal(P,S) A number or a string 14.20, "14.20"
date A string in the form YYYY-MM-DD "2026-01-15"
time A string in the form HH:MM:SS, with up to 6 fractional digits (microseconds) "13:45:30.123"
timestamp A string in the form <date>T<time>, with no time zone "2026-01-15T13:45:30"
timestamptz A string in the form <date>T<time>, followed by Z or a UTC offset "2026-01-15T13:45:30Z", "2026-01-15T14:45:30+01:00"
timestamp_ns, timestamptz_ns The same as timestamp and timestamptz, with up to 9 fractional digits (nanoseconds) "2026-01-15T13:45:30.123456789Z"
string A string "Alice"
uuid A string in the hyphenated form "123e4567-e89b-12d3-a456-426614174000"
binary, fixed(L) The bytes, encoded in standard base64 "3q2+7w=="
geometry, geography A well-known binary (WKB) value, as a hexadecimal or base64 string "0101000000000000000000f03f000000000000f03f"
variant An object with exactly two keys, metadata and value, each a base64 string {"metadata": "AQAA", "value": "DCo="}
struct An object {"city": "Seattle"}
list An array [1, 2, 3], []
map An object. For more information, see Maps in JSON. {"a": 1, "b": 2}
unknown null, or leave out the key null
Any optional column null, to write a null null
Any column with a default Leave out the key, to write the default

Note the following for specific types:

  • Integers – PutRows accepts a value with a fraction or an exponent, such as 42.0 or 4.2E1, only when it's a whole number. For a long column, the magnitude of the value must also be at most 2^53 - 1 (9,007,199,254,740,991). This prevents propagating the precision loss that JSON number encoding could have caused. Write larger values without a fraction or exponent, for example 1234567890123456789, or as a string. PutRows doesn't accept leading zeros, a leading +, or -0 .

  • Decimals – PutRows reads a decimal from its exact text, so no precision is lost to floating-point conversion. Exponent notation, such as 1.42E1, is accepted. Extra fractional digits are accepted only when they're zero. For example, for a decimal(4,2) column, 14.200 is accepted as 14.20, but 14.201 is rejected. To avoid rounding issues, we recommend that you write decimals as strings with fixed point, for example "14.20".

  • Dates – The year must have four digits, from 0000 to 9999. The day must exist in the proleptic Gregorian calendar, which extends the Gregorian calendar to dates before 1582.

  • Timestamps with a time zone – PutRows converts the value to UTC and doesn't keep the offset. For example, "2026-01-01T10:00:00+01:00" and "2026-01-01T09:00:00Z" are the same value.

  • UUIDs – Uppercase and lowercase letters are accepted. Braces, a urn:uuid: prefix, and the form without hyphens aren't accepted.

  • Binary – Use standard base64 with padding.

  • Geometry and geography – Send WKB, not well-known text (WKT). Well-known text is not supported. A hexadecimal value starts with 0, and a base64 value starts with A.

  • Variant – Send the unshredded Parquet variant encoding. Shredded variants aren't accepted.

Maps in JSON

How you write a map depends on the map's key type.

  • For keys of a simple type, such as string, int, date, or uuid, write the map as a JSON object. Each member name is the key, written in the same form as a string value of that type. For example, in a map<int, string> column, {"2": "a"} writes the key 2.

  • For keys of type struct, list, or map, JSON can't represent the keys as member names. PutRows doesn't yet support these maps in JSON. For more information, see Payload format limitations.

  • A map whose key is or contains geometry or geography can only be null or empty. PutRows rejects every request to a table that has a map key of type variant, fixed(0), or unknown, or that contains one of these types at any depth.

PutRows rejects duplicate keys. Two keys are duplicates when their values are equal, regardless of how they're written. For example, "1" and "1.0" are the same key in a map with double keys.