How to parse JSON from stdin at Native Messaging host?

前端 未结 1 607
佛祖请我去吃肉
佛祖请我去吃肉 2020-12-22 07:20

Utilizing the code at How do I use a shell-script as Chrome Native Messaging host application as a template and given the file file.json which contains

相关标签:
1条回答
  • 2020-12-22 08:13

    Assuming that file.json contains the JSON as indicated, I believe all you will need is:

    json=$(jq '{message: .}' file.json)
    

    If you then echo "$json", the result will be:

    {
      "message": {
        "text": "abc"
      }
    }
    
    0 讨论(0)
提交回复
热议问题