lawsg icon indicating copy to clipboard operation
lawsg copied to clipboard

Parsing JSON fields

Open pecigonzalo opened this issue 6 years ago • 3 comments

Hello! im coming from awslogs and really interested in this tool, but I would like to know if there is a way to prase fields from JSON, as our events are stored in JSON format.

Thanks!

pecigonzalo avatar Oct 30 '18 09:10 pecigonzalo

Hello @pecigonzalo ! What do you have in mind? I have some JSON parsing bits from a different project. Curious how you might want that implemented.

mmcquillan avatar Nov 15 '18 13:11 mmcquillan

@mmcquillan basically using json.marshall or similar to get JSON to print correctly. I have a quick patch that does it for this repo, but i ended up forking cwlogs and adding some features I need there.

var result map[string]interface{}
err := json.Unmarshal([]byte(message), &result)

example code

pecigonzalo avatar Nov 15 '18 15:11 pecigonzalo

Thanks! I guess I was wondering what you envisioned in terms of how the cli would let you specify json and then specify the formatting you'd like to express?

mmcquillan avatar Nov 16 '18 02:11 mmcquillan