how to convert the query result data to json format in kusto query language

Viewed 3423

I'm working on a logic app which will create a bug I have to display description in the work item like below:

{
    "Description":
    {
        "Title":"", 
        "Validation step":"",
        "OperationActivityId:":"",
        "Environment detailsLink":"",
        "Please click here":"",
        "ErrorMessage":""
    }
}

I'm Querying all above mentioned fields as result of query from Kusto(KQL) and getting all the required fields but I don't know how to convert it to make it Json. Can anyone help me on this..?

Thanks in advance.

1 Answers

Here you go:

PackedRecordlet MyTable = datatable(Category:string, Value:long) [
   "A", 1,
   "A", 3,
   "A", 5,
   "B", 1,
   "B", 2
];
MyTable
| extend PackedRecord = pack_all()
| summarize Result = make_list(PackedRecord)

This will output everything in a nice json:

[
  {
    "Category": "A",
    "Value": 1
  },
  {
    "Category": "A",
    "Value": 3
  },
  {
    "Category": "A",
    "Value": 5
  },
  {
    "Category": "B",
    "Value": 1
  },
  {
    "Category": "B",
    "Value": 2
  }
]

Explanation

Related