table2json

table2json(t) converts the table object t into a json string.

Examples

>> Name = {'John';'Marc';'Sam';'Toni'}
Grades = {'B';'A';'B';'F'}
DOB = {'02-Jun-2012';'12-Feb-2012';'04-Oct-2011';'29-Aug-2012'}
T = table(Name,Grades,DOB,'VariableNames',{'First_Name' 'Grade' 'Date_birth'})#

 First_Name Grade   Date_birth 
       John     B  02-Jun-2012 
       Marc     A  12-Feb-2012 
        Sam     B  04-Oct-2011 
       Toni     F  29-Aug-2012 

>> table2json(T)#

{
  "First_Name": ["John", "Marc", "Sam", "Toni"], 
  "Grade": ["B", "A", "B", "F"], 
  "Date_birth": ["02-Jun-2012", "12-Feb-2012", "04-Oct-2011", "29-Aug-2012"]
}

See also

json | table2dataframe | table