JSON Extract, Reformat and Print
Improved.<p><pre><code>     &#x2F;* extract, reformat, print json *&#x2F;
        
     int dprintf(int, const char *__restrict, ...);
     int fileno (FILE *);
     int x,y,z;
     #define echo do{if(fwrite(yytext,(size_t)yyleng,1,yyout)){}}while(0)
     #define jmp (yy_start) = 1 + 2 *
     #define pc(x) putchar(x)
     #define dbg(x) dprintf(3,&quot;%s\t%s\n&quot;,x,yytext);
    %option nounput noinput noyywrap
    %s boolean brace bracket bracketbrace number quotes
    %%
    \40\40+
    \11+
    \12
     &#x2F;* boolean
       +-------------------+
       | &quot;key&quot;:true        |
       | &quot;key&quot;: true       |
       +-------------------+
     *&#x2F;
    \&quot;[^\&quot;:\]\)=]*\&quot;:\40*&quot;(true)|(false)&quot; {
     dbg(&quot;&lt;&lt;boolean&gt;&gt;&quot;);
     pc(10);
     echo;
     jmp boolean;}
    &lt;boolean&gt;[e\}] pc(101);jmp 0;
    &lt;boolean&gt;[^\}] echo;
     &#x2F;* brace
       +-------------------+
       | &quot;key&quot;:{           |
       | &quot;key&quot;: {          |
       +-------------------+
     *&#x2F;
    \&quot;[^\&quot;:\]\)=]*\&quot;:\40*\{ {
     dbg(&quot;&lt;&lt;brace&gt;&gt;&quot;);
     pc(10);
     echo;
     jmp brace;}
    &lt;brace&gt;\} jmp 0;
    &lt;brace&gt;[^\}] echo;
     &#x2F;* bracket 
       +-------------------+
       | &quot;key&quot;:[           |
       | &quot;key&quot;: [          |
       | &quot;key&quot;:[           |
       |  &quot;value&quot;          |
       | &quot;key&quot;: [          |
       |  &quot;value&quot;          |
       | &quot;key&quot;:[           |
       |  &quot;[value]&quot;        |
       | &quot;key&quot;: [          |
       |  &quot;[value]&quot;        |
       +-------------------+            
     *&#x2F;
    \&quot;[^\&quot;:\]\)=]*\&quot;:\40*\[ {
     dbg(&quot;&lt;&lt;bracket&gt;&gt;&quot;);
     pc(10);
     echo;
     jmp bracket;}
    &lt;bracket&gt;\] echo;jmp 0;
    &lt;bracket&gt;[^\]] echo;
     &#x2F;* bracket + brace
       +-------------------+
       | &quot;key&quot;:[{          |
       | &quot;key&quot;: [{         |
       +-------------------+
     *&#x2F;
    \&quot;[^\&quot;:\]\)=]*\&quot;:\40*\[\40*\{ {
     dbg(&quot;&lt;&lt;bracket+brace&gt;&gt;&quot;);
     pc(10);
     echo;
     jmp bracketbrace;}
    &lt;bracketbrace&gt;\] jmp 0;
    &lt;bracketbrace&gt;[^\]\}] echo;
     &#x2F;* number
       +-------------------+
       |&quot;key&quot;:1            |
       |&quot;key&quot;: 1           |
       +-------------------+
     *&#x2F;
    \&quot;[^\&quot;:\]\)=]*\&quot;:\40*[0-9\40\12\15]* {
     dbg(&quot;&lt;&lt;number&gt;&gt;&quot;);
     pc(10);
     echo;
     jmp number;}
    &lt;number&gt;, jmp 0;
    &lt;number&gt;[^,\}\]] echo;
     &#x2F;* quotes
       +-------------------+
       | &quot;key&quot;:&quot;           |
       | &quot;key&quot;: &quot;          |
       +-------------------+
     *&#x2F;
    \&quot;[^\&quot;:\]\)=]*\&quot;:\40*\&quot; {
     dbg(&quot;&lt;&lt;quotes&gt;&gt;&quot;);
     pc(10);
     echo;
     jmp quotes;}
    &lt;quotes&gt;\&quot; echo;jmp 0;
    &lt;quotes&gt;[^\&quot;] echo;
    \n|.
    %%
    int main(){ yylex();pc(10);exit(0);}</code></pre>