cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Frequent Visitor

Help - null data when using JSON parser expecting array

Processing a web JSON response with json parser the array is inaccessible in the Apply to each.  Any help is appreciated as this is a problem with multiple web services being consume.

 

Sample JSON and screenshot of flow and error are below. 

 

Thanks!

 

Sample JSON

{"body":{"candles":[{"open":132.32,"high":132.4,"low":131.77,"close":131.8,"volume":99049,"datetime":1598958000000},{"open":131.8,"high":131.89,"low":131.7,"close":131.89,"volume":54191,"datetime":1598958060000},{"open":131.81,"high":131.9,"low":131.77,"close":131.8,"volume":18279,"datetime":1598958120000},{"open":131.79,"high":132.0,"low":131.79,"close":132.0,"volume":11582,"datetime":1598958180000},{"open":131.99,"high":132.1,"low":131.9,"close":132.08,"volume":20003,"datetime":1598958240000},{"open":132.08,"high":132.1,"low":131.99,"close":132.0,"volume":21609,"datetime":1598958300000},{"open":132.0,"high":132.0,"low":131.9,"close":131.93,"volume":15810,"datetime":1598958360000},{"open":131.91,"high":131.95,"low":131.88,"close":131.94,"volume":21655,"datetime":1598958420000}],"symbol":"AAPL","empty":false}}

 

eltrain_0-1600292713980.png

 

1 ACCEPTED SOLUTION

Accepted Solutions
Community Support
Community Support

Hi @eltrain ,

 

Do you want to Apply to each candles to add items?

Please take a try to parse your JSON, and you could refer to screenshot below to create the flow:

1.png

The schema in the Parse JSON as below:

{
    "type": "object",
    "properties": {
        "body": {
            "type": "object",
            "properties": {
                "candles": {
                    "type": "array",
                    "items": {
                        "type": "object",
                        "properties": {
                            "open": {
                                "type": "number"
                            },
                            "high": {
                                "type": "number"
                            },
                            "low": {
                                "type": "number"
                            },
                            "close": {
                                "type": "number"
                            },
                            "volume": {
                                "type": "integer"
                            },
                            "datetime": {
                                "type": "integer"
                            }
                        },
                        "required": [
                            "open",
                            "high",
                            "low",
                            "close",
                            "volume",
                            "datetime"
                        ]
                    }
                },
                "symbol": {
                    "type": "string"
                },
                "empty": {
                    "type": "boolean"
                }
            }
        }
    }
}

The expression for the candles in my flow as below:

body('Parse_JSON')?['body']?['candles']

 

Best Regards,

Alice

 

Community Support Team _ Alice Zhang
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

2 REPLIES 2
Solution Sage
Solution Sage

Hi @eltrain ,

 

Looks good JSON. Possibility is that you are getting null data from source. Ideally in that situation better to keep null check before entering into Apply to each loop. 

 

empty(body('Parse_JSON_2')?['body']?['candles']) and check with true on RHS
 
Thanks
Community Support
Community Support

Hi @eltrain ,

 

Do you want to Apply to each candles to add items?

Please take a try to parse your JSON, and you could refer to screenshot below to create the flow:

1.png

The schema in the Parse JSON as below:

{
    "type": "object",
    "properties": {
        "body": {
            "type": "object",
            "properties": {
                "candles": {
                    "type": "array",
                    "items": {
                        "type": "object",
                        "properties": {
                            "open": {
                                "type": "number"
                            },
                            "high": {
                                "type": "number"
                            },
                            "low": {
                                "type": "number"
                            },
                            "close": {
                                "type": "number"
                            },
                            "volume": {
                                "type": "integer"
                            },
                            "datetime": {
                                "type": "integer"
                            }
                        },
                        "required": [
                            "open",
                            "high",
                            "low",
                            "close",
                            "volume",
                            "datetime"
                        ]
                    }
                },
                "symbol": {
                    "type": "string"
                },
                "empty": {
                    "type": "boolean"
                }
            }
        }
    }
}

The expression for the candles in my flow as below:

body('Parse_JSON')?['body']?['candles']

 

Best Regards,

Alice

 

Community Support Team _ Alice Zhang
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

Helpful resources

Announcements
Community Conference

Power Platform Community Conference

Check out the on demand sessions that are available now!

MPA Community Blog

Power Automate Community Blog

Check out the community blog page where you can find valuable learning material from community and product team members!

Top Solution Authors
Top Kudoed Authors
Users online (7,205)