First Objective :My objective is to parse a file (“Status.json”), search for a specific line of text (“last_communicated_timestamp”) and return that string of text , “last_communicated_timestamp”: “2019-11-04T08:48:53-08:00”, I’ve read through most of the posts and tried massaging similar scripts but can’t get it right to obtain the desired result.This is a sample of what I’ve tried so far and many iterations (of it) since:
following texts of firsts “last_communicated_timestamp” of lines whose (it starts with “last_communicated_timestamp”) of file “C:\Users\Administrator\Documents\Brown\Status.json”
I am dealing with the line starts with Some thing like lines starting with “ and contains “last_communicated_timestamp” so i was looking at how to modify above using
Might I recommend the use of the built-in JSON inspectors?
q: values of keys "last_communicated_timestamp" of values of keys "ProductInfo" of jsons of files "c:\temp\test.json"
A: 2019-11-04T08:48:53-08:00
One stumbling point for me was trying to get out of the habit of “values of keys of keys” the way we would traverse the Regstry; for JSON it’s “values of keys of values of keys” instead.
My objective is to parse a file (“master.log”), search for a the last line of the file that has specific line of text (xsrpc connection is active) and return the preceding string of text which is the timestamp”:0927/163753z” that proceeds the text. Here is the entire line with the timestamp in bold. The log file is continuous and I will need to run this process once a day and capture the last line of the file that meets below. I can show entire line or just the time stamp either way.
[0927/155747z:INFO:xsrpc_controller.cc(178)] xsrpc connection is active
Just word of caution, when looking into parsing files. You might want to put the parsing to evaluate only IF the file is of certain size, not blindly. lines of is going to parse the entire file line by line to get you the lines you are interested and if the file is let’s say 5-10-50-100mbs in size it really can cause significant performance issues.