Show HN: Convert json dns data to csv
cat json.l
#define echo ECHO
#define jmp BEGIN
#define p printf
#define nl p("\n")
#define s p(",")
%s xa xb xc xd
xa "\"Question\":[{\"name\": \""
ya "\", \"type\": 1}],"
xb "\"type\": 1,"
yb "\"data\": \""
xc \"
%%
{xa} jmp xa;
<xa>{ya} s;jmp xb;
<xa>. echo;
<xb>{xb} jmp xc;
<xb>.
<xc>{yb} jmp xd;
<xc>.
<xd>{xc} nl;jmp 0;
<xd>. echo;
\n
.
%%
int main(){ yylex();}
int yywrap(){}
/* compile with something like:
flex -Crfa -8 -i json.l
cc -pipe lex.yy.c -static -o json
usage example: json < file.json > file.csv
*/
1 comment
[ 2.9 ms ] story [ 12.3 ms ] thread