CSVJF - CSVJF (CSV with JSON Fields) file format specification
0.1
This document describes version 0.1.2 of CSVJF (from Perl distribution CSVJF), released on 2021-08-08.
Draft series (0.x), might still change. Will be stable in 1.0.
CSVJF (short for "CSV with JSON field") is an extension to the CSV format to allow fields that contain JSON string, arrays, or hashes (objects).
The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be interpreted as described in RFC 2119.
CSV is a convenient format to generate or write manually. However, it does not allow fields to be a data structure.
CSVJF extends the CSV specification as follows:
A CSV file is zero or more lines, separated by newlines. Each line represent a row of fields.
The first line may be a header line.
Each line is a comma-separated list of fields.
A field is either an unquoted string, a JSON-encoded string, a JSON-encoded array, or a JSON-encoded hash (object).
An unquoted string must not contain the record separator character (newline) or field separator character (comma). If the field wants to contain these characters it must be written as a JSON-encoded string. It also must not start with opening square bracket ("[") or opening curly brace ("{") because those characters are used for JSON array and hash, respectively.
A JSON-encoded string is string enclosed in double quotes ("). Escaping follows JSON rules.
A JSON-encoded array is string enclosed in square brackets ("[" and "]").
A JSON-encoded hash is string enclosed in curly braces ("{" and "}").
Some examples of CSVJF rows:
one,two,three "field one with spaces","field two with newline and com,ma,s",field 3,["field5","array"],{"field6":"hash"}
Please visit the project's homepage at https://metacpan.org/release/CSVJF.
Source repository is at https://github.com/perlancar/perl-CSVJF.
Please report any bugs or feature requests on the bugtracker website https://rt.cpan.org/Public/Dist/Display.html?Name=CSVJF
When submitting a bug or request, please include a test-file or a patch to an existing test-file that illustrates the bug or desired feature.
CSVJ file format, https://csvj.org/. This file format attempts to standardize the CSV format with JSON rules. It's basically JSON array with the "[" and "]" square brackets removed (implied), with additional restriction of elements cannot be array/object. Thus, every string field must be quoted except when a field is a number, boolean true/false literal, or null. Note that despite the similar name, CSVJ and CSVJS are unrelated.
true
false
null
IOD format specification, IOD, which also employs the use of encoding prefixes ", [ and { to embed JSON string, array, and hash, respectively.
"
[
{
perlancar <perlancar@cpan.org>
This software is copyright (c) 2021, 2019 by perlancar@cpan.org.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
To install CSVJF, copy and paste the appropriate command in to your terminal.
cpanm
cpanm CSVJF
CPAN shell
perl -MCPAN -e shell install CSVJF
For more information on module installation, please visit the detailed CPAN module installation guide.