Q:

How to insert comma after the certain character? 

How can I insert a comma after a certain character but do not insert comma for the last record.  
I have data 
[
{"ID": 12345}
{"ID": 67891}
{"ID": 14785}
]

so I am trying to insert a comma after every } except the last one.  
So the update should be like this: 
[
{"ID": 12345},
{"ID": 67891},
{"ID": 14785}
]

Can someone please help me with this?  

A:

$ awk '/^{/ { if (lastline ~ "}$") lastline=lastline ","; print lastline; }; '\
'!  /^{/ && NR>1 { print lastline; }; { lastline=$0; }; '\
'END { print lastline; }' inputfile
[
{"ID": 12345},
{"ID": 67891},
{"ID": 14785}
]
[
{"ID": 12345},
{"ID": 67891},
{"ID": 14785}
]

