tsvtojson(
tsvtojson(
TSVTEXT
)

The tsvtojson( function converts tab separated text into JSON formatted text.

Parameters

This function has one parameter:

tsvtext – text containing tab separated values. The first line of text contains the titles for each column of text. Each subsequent line must contain the actual data items in the same order. The lines must be separated by carriage returns.

Description

This function converts tab separated text into JSON code. For example, suppose you have a tab file named Directory.tsv that contains data like this (the ▷ symbol represents tab characters):

    Name ▷ Phone ▷ Email
    Adams, Dorothy ▷ 555-3000 ▷ dadams@gmail.com
    Franklin, Mark ▷ 555-4822 ▷ mfranklin@hotmail.com
    Smith, John ▷ 555-1212 ▷ jsmith@yahoo.com
    Wilson, Judy ▷ 555-9324 ▷ jwilson@acme.net

This data can be read into a variable and converted to comma separated format:

    local phoneNumbers
    phoneNumberJSON=tsvtossv(fileload("Directory.tsv"))

The phoneNumberJSON variable now contains the same data, but converted into JSON format (the JSON format is frequently used in web coding).

    [
    {
      "Name"  : "Adams, Dorothy",
      "Phone" : "555-3000",
      "Email" : "dadams@gmail.com"
    },
    {
      "Name"  : "Franklin, Mark",
      "Phone" : "555-4822",
      "Email" : "mfranklin@hotmail.com"
    },
    {
      "Name"  : "Smith, John",
      "Phone" : "555-1212",
      "Email" : "jsmith@yahoo.com"
    },
    {
      "Name"  : "Wilson, Judy",
      "Phone" : "555-9324",
      "Email" : "jwilson@acme.net"
    }
    ]

See Also

- arrayfilter( -- processes each element of a text array or a data array with a formula (see Text Arrays and Data Arrays).
- csvexportline( -- generates a comma delimited line of data containing all the fields in the current record.
- csvexportlinevisiblecells( -- generates a comma delimited line of data containing all the visible (non hidden) fields in the current record.
- csvquoted( -- adds quotes if necessary for CSV text (RFC 4180).
- csvtotsv( -- converts comma separated text into tab separated text.
- databaseexportcsv -- exports selected records in the current database in CSV format (comma separated) to a text file.
- databaseexportjson -- exports selected records in the current database in JSON format to a text file.
- databaseexporttsv -- exports selected records in the current database in TSV format (tab separated) to a text file.
- databaseexportusingformula -- exports selected records in the current database to a text file, using a formula.
- downloadpartialdatabase -- downloads specified components of the current database from the server. The current database must be shared.
- export -- exports the selected rows in the current database into a text file.
- exportjson -- exports the current database in JSON format.
- HTML Export -- custom exports into an HTML file.
- Import Database -- importing another database into the current database.
- import( -- returns a line or element of imported data. This function works in conjunction with repetitive operations like importtext, arrayfilter(, characterfilter( etc.
- importcell( -- returns one cell of imported data.
- importdatabase -- imports data from another database into the current database.
- importjson -- imports a JSON array into the current database.
- importjsonline -- imports a JSON record into the current record.
- importline -- imports a line of text into the current record.
- importrawdata -- imports raw binary data into an existing database.
- importtext -- imports text into an existing database.
- jsonexport( -- converts a Panorama dictionary or data array into JSON.
- jsonexportline( -- exports the current database record in JSON format.
- jsonimport( -- converts JSON into a Panorama dictionary or data array.
- jsonscriptstring( -- converts text into a JSON string literal
- newdatabasewithjson -- creates a new database using a JSON file.
- newdatabasewithtextfieldnames -- creates a new database from a text file. The text file must contain the field names in the first line.
- newdatabasewithtextfile -- creates a new database from a plain text file. The fields will be named A, B, C, etc.
- partialdatabaseupdate -- updates one or more components of an existing database.
- savepartialdatabase -- saves specified components of the current database, leaving other components out.
- seq( -- returns sequential numbers (1, 2, 3, etc.).
- Text Export -- exporting a database into a text or HTML file.
- Text Export Wizard -- custom exports into a text or HTML file.
- Text Import -- importing text into an existing database.
- tsvtocsv( -- converts tab separated text into comma separated text.

History

Version | Status | Notes
10.2 | New | New in this version.