cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Resolver I
Resolver I

String to Integer in a Parse JSON from an Array

Hi, 

 

I'm having problems with invalid types of data in my scenario and would be great if someone could give some hint.

 

My scenario is doing the following:

  1. getting the tables on an excel file
  2. Listing the rows on the table
  3. Storing the list of rows in an Array called Table_Output
  4. Using Parse JSON with a defined Schema to work with the previous data.

This is my table

Table.JPG

And this is my flow

Flow PRocess.JPG

 

This is the content in the Parse JSON

 

[
  {
    "@odata.etag": "",
    "ItemInternalId": "f2d1e93b-f1a2-42ad-886d-a1290d1156df",
    "Name": "John",
    "Value": "3",
    "City": "London"
  },
  {
    "@odata.etag": "",
    "ItemInternalId": "91c8c219-5cbb-4fb8-b738-90074940e4d7",
    "Name": "Jack",
    "Value": "1",
    "City": "Chicago"
  },
  {
    "@odata.etag": "",
    "ItemInternalId": "471edf2d-bd99-4cc5-b901-0549a9560b82",
    "Name": "Jill",
    "Value": "8",
    "City": "Madrid"
  }
]

 

 

And this is the JSON Schema

 

{
  "type": "array",
  "items": {
    "type": "object",
    "properties": {
      "Name": {
        "type": "string"
      },
      "Value": {
        "type": "integer"
      },
      "City": {
        "type": "string"
      }
    },
    "required": [
      "Name",
      "Value",
      "City"
    ]
  }
}

 

 

The issue is that [Value] is expecting an integer but it is getting from the Table_Output array an string.

 

 

[
  {
    "message": "Invalid type. Expected Integer but got String.",
    "lineNumber": 0,
    "linePosition": 0,
    "path": "[0].Value",
    "value": "3",
    "schemaId": "#/items/properties/Value",
    "errorType": "type",
    "childErrors": []
  },
  {
    "message": "Invalid type. Expected Integer but got String.",
    "lineNumber": 0,
    "linePosition": 0,
    "path": "[1].Value",
    "value": "1",
    "schemaId": "#/items/properties/Value",
    "errorType": "type",
    "childErrors": []
  },
  {
    "message": "Invalid type. Expected Integer but got String.",
    "lineNumber": 0,
    "linePosition": 0,
    "path": "[2].Value",
    "value": "8",
    "schemaId": "#/items/properties/Value",
    "errorType": "type",
    "childErrors": []
  }
]

 

 

I've tried to use the formula int() to convert in the array to integer, but I can't target the correct column,  but it is not working. I've also tried to change the schema to get a string (this is working) and then change Value to integer, but again it is not working. If I try a Compose to convert to integer value, it is not displaying the field "Value" in the Data Operation, only the {body}.

 

Parse JSON.JPG

 

Any suggestion how I can convert a String to Integer there?

 

Many thanks

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Community Support
Community Support

Hi @Sam4,

 

You could use the Select action to convert the String into Integer.

 

Annotation 2020-07-02 150000.jpg

 

Run result:

Annotation 2020-07-02 145913.jpg

 

Best Regards,
Community Support Team _ Lin Tu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

5 REPLIES 5
Highlighted
Super User III
Super User III

hi @Sam4  you can try by deleting the type 

      "Value": {
        "type": "integer"
      },


Did I answer your question? Please consider to Mark
my post as a solution! to guide others :winking_face:

Proud to be a Flownaut!


If you want you can follow me at www.christianabata.com Quieres contenido en español? Síguenos en Power Automate LA
Highlighted

Thanks @ChristianAbata , 

 

If I take the Value out from the Schema, I still get it as a String in the Parse JSON Output. I think that I need to prepare the value before using the Schema or using an intermediate step that I am missing.

 

Check.JPG

 

 

 

Highlighted

@Sam4  if you need to get an specific value yes what I did is exactly what you said I preparate my Squema to get the type I need. But see is you delete the type in your schema

"Value": {
        "type": "integer"
      },

 

Like this

 

"Value": {
      },

 

You can use your value no matters what tipe of value you are going to receive even Null values, so then you can manage that result using expressions.

 

So for example if you want to use int values you can add a compose action an then add the expression int('HERE YOUR JSON PROPERTIE') to transform what you send into an integer value the same as Strig or other data type.



Did I answer your question? Please consider to Mark
my post as a solution! to guide others :winking_face:

Proud to be a Flownaut!


If you want you can follow me at www.christianabata.com Quieres contenido en español? Síguenos en Power Automate LA
Highlighted
Community Support
Community Support

Hi @Sam4,

 

You could use the Select action to convert the String into Integer.

 

Annotation 2020-07-02 150000.jpg

 

Run result:

Annotation 2020-07-02 145913.jpg

 

Best Regards,
Community Support Team _ Lin Tu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

Highlighted

Thanks @v-litu-msft that was exactly what I was looking for. My scenario is working now. 

 

Kind Regards 

Helpful resources

Announcements
Community Conference

Power Platform Community Conference

Check out the on demand sessions that are available now!

Power Platform ISV Studio

Power Platform ISV Studio

ISV Studio is designed to become the go-to Power Platform destination for ISV’s to monitor & manage published applications.

Top Solution Authors
Top Kudoed Authors
Users online (9,910)