Here is an alternative method to create a single json array from an entire json column.
Running .jk on a single line will be more efficient than running .jk on many small arrays / dictionaries / lines.
// test table q)c:([] date:2?.zd ; client:( "{ \"firstName\": \"John\", \"lastName\": \"Smith\", \"age\": 27 }" ; "{ \"firstName\": \"Scott\", \"lastName\": \"Tiger\", \"age\":29 }" ) ); // combine each string with "," and encompass in "[]" // join each parsed dictionary with each row from c, keep client column for keep sake q)c,'exec .jk {"[",x,"]"}"," sv client from c
It often happens with json capture that data and messages are schematic / unstructured. If, in this case, each json line does not have to have the same tags as the others, then you can create a static map of your required output and connect this map with each parsed json message. Then this will always affect the permission to the table. You can also enter a map to make sure the resulting table is entered correctly.
// insert row with missing age tag and new location tag q)`c insert (.zd;"{\"firstName\": \"Sean\", \"lastName\": \"O'Hagan\", \"location\" : \"Dub\"}"); // name and locations are strings, age is float q)map:{x,'first each x$\:()}[`firstName`lastName`age`location!10 10 9 11h]; // manually edit symbol nulls to be varchars, so when casting to symbol the RHS param is always a varchar q).[`map;where map[;1]~\:`;:;(-11h;" ")]; // join map to each parsed dictionary, and delete client column as we have extracted useful data q)delete client from c,'exec flip map[;0]$flip (map[;1],/:.jk {"[",x,"]"}"," sv client) from c date firstName lastName age location ------------------------------------------- 2004.02.01 "John" "Smith" 27 2005.06.06 "Scott" "Tiger" 29 2018.03.13 "Sean" "O'Hagan" Dub q)meta delete client from c,'exec flip map[;0]$flip (map[;1],/:.jk {"[",x,"]"}"," sv client) from c c | tfa ---------| ----- date | d firstName| C lastName | C age | f location | s
HTH, Sean