Monday, February 20, 2012

My market, a straight shot to Json

In the Qson system, this code, right here, is shuffling data from Sqlite3 to whatever Json receiver want it, console, network, or file. But this is high speed stepping through a Qson table using Sqlite embedded function call, prepared statements, and high speed bindings. If you want Json fast, want it searchable, want it free and simple; what can I say?

int   table_to_Json(TABLE *t,Webaddr * to) {
  int len; int i,rows;
  Triple Qin;char * key_value;char tmp[9];
  Code stmt;
  stmt = start_table(t,pop_operator);
  // peek at the header
  i = machine_step_fetch(&Qin,0);
  rows = Qin.pointer;
  for(i=0;i<rows;i++) {
    if(i) machine_step_fetch(&Qin,0);
    len = machine_key_len(stmt);
    send_(Qin.key,len,to);
    send_(tmp,sprintf(tmp,"%c",Qin.link),to);
  }
This transmission automatically closes on balanced brackets.

No comments: