0

I have a azure logic app that receives an input json string. I would like to pass this over to a JSON to Table action. However, I am having difficulties as the JSON to Table needs an input of type object. After researching I thought I need to parse the string first and then give the body of the parse json action as the input to the JSON to Table action.

enter image description here

enter image description here

I am not sure what the correct expression for the entire JSON object after the Parse JSON action is. I have tried with @{body('Parse_JSON')} (what chatgbt suggestsed) but it gives 'invalid expression'. Would anyone know the correct expression?

On another note, I've noticed that when I manually insert the entire string in the Data field of JSON to Table it works fine. When I intiated a variable of type object with the string as the value it worked as well. However, I have not found a way to integrate to Content of my trigger. When I pass the Content directy to the JSON to Table I get the error: Unable to cast object of type 'Newtonsoft.Json.Linq.JValue' to type 'Newtonsoft.Json.Linq.JContainer'.

My input string looks something like this:

{
  "comment": null,
  "data": {
    "id": "123",
    "Person": {
      "Name": "Testmann",
      "Firstname": "Tim"
    },
    "Timestamp": "2023-03-22T20:16:04.663252+01:00",
    "Fotos_Apppletree": [
      {
        "photo_description_1": null,
        "_1_Foto_Appletree": {
          "fileId": "10",
          "fileName": "Appletree_2023_03_22_19_16_09.png",
          "timestamp": "2023-03-22T19:16:09.082243Z",
          "size": 63865,
          "url": "https://path10"
        }
      },
      {
        "photo_description_2": null,
        "_1_Foto_Appletree": {
          "fileId": "11",
          "fileName": "Appletree_2023_03_22_19_16_15.png",
          "timestamp": "2023-03-22T19:16:15.082243Z",
          "size": 63865,
          "url": "https://path11"
        }
      }
    ]
  }
}

Does anyone know how to tackle this string/object problem. Thanks a lot for any help!

Anna
  • 81
  • 5
  • Can you add your expected output for above json and I guess as this is not a regular json , you need to do manually(for that you can use Create html table connector ). – RithwikBojja Jun 14 '23 at 12:47
  • I managed to solve the issue by regenerating the shema of the parse json so then the body expression worked – Anna Jun 14 '23 at 15:28

1 Answers1

1

I do agree @Anna that Parse_Json Shemea generation is the key here,

My Design:

enter image description here

Parse Json Schema:

{
    "type": "object",
    "properties": {
        "comment": {},
        "data": {
            "type": "object",
            "properties": {
                "id": {
                    "type": "string"
                },
                "Person": {
                    "type": "object",
                    "properties": {
                        "Name": {
                            "type": "string"
                        },
                        "Firstname": {
                            "type": "string"
                        }
                    }
                },
                "Timestamp": {
                    "type": "string"
                },
                "Fotos_Apppletree": {
                    "type": "array",
                    "items": {
                        "type": "object",
                        "properties": {
                            "photo_description_1": {},
                            "_1_Foto_Appletree": {
                                "type": "object",
                                "properties": {
                                    "fileId": {
                                        "type": "string"
                                    },
                                    "fileName": {
                                        "type": "string"
                                    },
                                    "timestamp": {
                                        "type": "string"
                                    },
                                    "size": {
                                        "type": "integer"
                                    },
                                    "url": {
                                        "type": "string"
                                    }
                                }
                            },
                            "photo_description_2": {}
                        },
                        "required": [
                            "_1_Foto_Appletree"
                        ]
                    }
                }
            }
        }
    }
}

Next you can use your step of Json to Table.

Output Of Parse Json:

enter image description here

Then you can use Json to table with advanced connector , or you can use below connector also:

enter image description here

RithwikBojja
  • 5,069
  • 2
  • 3
  • 7