Writing tables to JSON

I’m trying to convert some table data to JSON for web usage. This is in 5Z, so bear with me…

I think there’s a problem with nested tables, but I don’t recall…any help is appreciated.

David C.
textfyre.com

[code][

{ “Hints” : [
[ {
“Title” : “How do I worb the frob?”,
“Hint” : [ “Does the frob want to be worbed?”,
“Do you have a worbing tool?”,
“Is your worb icon zammified?”
]
} ],
[ {
“Title” : “How do I worb the frob?”,
“Hint” : [ “Does the frob want to be worbed?”,
“Do you have a worbing tool?”,
“Is your worb icon zammified?”
]
} ]
] }

]
To write the active hints:
select the hint channel;
say “{ ‘hints’: [”;
repeat with N running from 1 to the number of rows in Table of Active Hints
begin;
choose row N in Table of Active Hints;
say "[{ ‘title’: ‘[title entry]’, ";
let hint-table be table entry;
say “‘hint’: [”;
repeat with N running from 1 to the number of rows in hint-table
begin;
choose row N in hint-table;
say “’[hint entry]’”
if N is less than the number of rows in hint-table, say “,”;
end repeat;
say “]}]”;
if N is less than the number of rows in the Table of Active Hints, say “,”;
end repeat;
say “] }”;
select the main channel.
[/code]

You can’t escape brackets with slashes in I7. You’ll have to use [bracket] etc.

I’ve gotten through this…I was pretty close…

{ "Hints" : [
  [ {
     "Title" : "How do I worb the frob?",
     "Hint" : [ "Does the frob want to be worbed?",
                     "Do you have a worbing tool?",
                     "Is your worb icon zammified?"
                  ]
  } ],
  [ {
     "Title" : "How do I worb the frob?",
     "Hint" : [ "Does the frob want to be worbed?",
                     "Do you have a worbing tool?",
                     "Is your worb icon zammified?"
                   ]
  } ]
] }

]
To write the active hints:
     select the hint channel;
     say "{ 'hints': [bracket]";
     repeat with N running from 1 to the number of filled rows in Table of Active Hints
        begin;
          choose row N in Table of Active Hints;
          if there is a title entry
          begin;
          say "[bracket]{ 'title': '[title entry]', ";
          let hint-table be subtable entry;
          say "'hint': [bracket]";
          repeat with O running from 1 to the number of rows in hint-table
            begin;
             choose row O in hint-table;          
              say "'[hint entry]'";
              if O is less than the number of rows in hint-table, say ",";
            end repeat;
            say "[close bracket]}[close bracket]";
          if N is less than the number of filled rows in the Table of Active Hints, say ",";
          end if;
        end repeat;
     say "[close bracket] }";
     select the main channel.

Is the compiling giving you errors? Which ones?

Also, why are the hints in an object in an array? You should be able to cut out that array as it only has one entry.