BUG: Fix redundant run of unwinding nested dictionary
State: closed

- [x] passes `git diff upstream/master -u -- "*.py" | flake8 --diff`

The original implementation of checking whether the json contains nested structure is wrong as it will return `True` even for a non nested json (e.g. `[{'x' : 1}]`). The changes ensures that `nested_to_record` is not called unnecessarily

Labels:
name: IO JSON
description: read_json, to_json, json_normalize

Comments:
Is this in reference to a particular issue? Typically prefer an issue to be created first with a minimally reproducible example for discussion (simple documentation fixes are excepted)
I don't think there is an issue catering to this yet. The current implementation would not produce wrong result, but will run some codes unnecessarily. Should I produce an issue for this? @WillAyd 
no need to make an actual issue but is there a performance boost or just code simplification? do our tests exercise this specifically?
There would be a performance boost for an array of non-nested json objects as they would not be looped through unnecessarily again which is the intention of the `if` statement (though the original implementation failed to achieve that). There is no test for this currently. @jreback 
@WillAyd Do you have any idea why the travis check failed?
Not sure might be a one off with the environment just restarted let’s see

Sent from my iPhone

> On Jul 3, 2019, at 12:49 AM, Jiang Yue <notifications@github.com> wrote:
> 
> @WillAyd Do you have any idea why the travis check failed?
> 
> —
> You are receiving this because you were mentioned.
> Reply to this email directly, view it on GitHub, or mute the thread.

# [Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/27046?src=pr&el=h1) Report
> Merging [#27046](https://codecov.io/gh/pandas-dev/pandas/pull/27046?src=pr&el=desc) into [master](https://codecov.io/gh/pandas-dev/pandas/commit/c7d7e81d544f3a6d2723037b8ae1e92c50b54d34?src=pr&el=desc) will **increase** coverage by `49.55%`.
> The diff coverage is `100%`.

[![Impacted file tree graph](https://codecov.io/gh/pandas-dev/pandas/pull/27046/graphs/tree.svg?width=650&token=eZ4WkYLtcO&height=150&src=pr)](https://codecov.io/gh/pandas-dev/pandas/pull/27046?src=pr&el=tree)

```diff
@@             Coverage Diff             @@
##           master   #27046       +/-   ##
===========================================
+ Coverage   42.44%      92%   +49.55%     
===========================================
  Files         180      180               
  Lines       50399    50754      +355     
===========================================
+ Hits        21394    46695    +25301     
+ Misses      29005     4059    -24946
```

| Flag | Coverage Δ | |
|---|---|---|
| #multiple | `90.64% <100%> (?)` | |
| #single | `41.82% <0%> (-0.63%)` | :arrow_down: |

| [Impacted Files](https://codecov.io/gh/pandas-dev/pandas/pull/27046?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [pandas/io/json/normalize.py](https://codecov.io/gh/pandas-dev/pandas/pull/27046/diff?src=pr&el=tree#diff-cGFuZGFzL2lvL2pzb24vbm9ybWFsaXplLnB5) | `96.93% <100%> (+87.93%)` | :arrow_up: |
| [pandas/core/api.py](https://codecov.io/gh/pandas-dev/pandas/pull/27046/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvYXBpLnB5) | `100% <0%> (ø)` | :arrow_up: |
| [pandas/core/arrays/\_\_init\_\_.py](https://codecov.io/gh/pandas-dev/pandas/pull/27046/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvYXJyYXlzL19faW5pdF9fLnB5) | `100% <0%> (ø)` | :arrow_up: |
| [pandas/core/dtypes/generic.py](https://codecov.io/gh/pandas-dev/pandas/pull/27046/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvZHR5cGVzL2dlbmVyaWMucHk=) | `100% <0%> (ø)` | :arrow_up: |
| [pandas/api/types/\_\_init\_\_.py](https://codecov.io/gh/pandas-dev/pandas/pull/27046/diff?src=pr&el=tree#diff-cGFuZGFzL2FwaS90eXBlcy9fX2luaXRfXy5weQ==) | `100% <0%> (ø)` | :arrow_up: |
| [pandas/io/clipboard/\_\_init\_\_.py](https://codecov.io/gh/pandas-dev/pandas/pull/27046/diff?src=pr&el=tree#diff-cGFuZGFzL2lvL2NsaXBib2FyZC9fX2luaXRfXy5weQ==) | `54.34% <0%> (ø)` | :arrow_up: |
| [pandas/core/internals/\_\_init\_\_.py](https://codecov.io/gh/pandas-dev/pandas/pull/27046/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvaW50ZXJuYWxzL19faW5pdF9fLnB5) | `100% <0%> (ø)` | :arrow_up: |
| [pandas/\_typing.py](https://codecov.io/gh/pandas-dev/pandas/pull/27046/diff?src=pr&el=tree#diff-cGFuZGFzL190eXBpbmcucHk=) | `100% <0%> (ø)` | :arrow_up: |
| [pandas/core/index.py](https://codecov.io/gh/pandas-dev/pandas/pull/27046/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvaW5kZXgucHk=) | `100% <0%> (ø)` | :arrow_up: |
| [pandas/api/extensions/\_\_init\_\_.py](https://codecov.io/gh/pandas-dev/pandas/pull/27046/diff?src=pr&el=tree#diff-cGFuZGFzL2FwaS9leHRlbnNpb25zL19faW5pdF9fLnB5) | `100% <0%> (ø)` | :arrow_up: |
| ... and [144 more](https://codecov.io/gh/pandas-dev/pandas/pull/27046/diff?src=pr&el=tree-more) | |

------

[Continue to review full report at Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/27046?src=pr&el=continue).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/27046?src=pr&el=footer). Last update [c7d7e81...505a519](https://codecov.io/gh/pandas-dev/pandas/pull/27046?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).

# [Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/27046?src=pr&el=h1) Report
> Merging [#27046](https://codecov.io/gh/pandas-dev/pandas/pull/27046?src=pr&el=desc) into [master](https://codecov.io/gh/pandas-dev/pandas/commit/c7d7e81d544f3a6d2723037b8ae1e92c50b54d34?src=pr&el=desc) will **increase** coverage by `49.55%`.
> The diff coverage is `100%`.

[![Impacted file tree graph](https://codecov.io/gh/pandas-dev/pandas/pull/27046/graphs/tree.svg?width=650&token=eZ4WkYLtcO&height=150&src=pr)](https://codecov.io/gh/pandas-dev/pandas/pull/27046?src=pr&el=tree)

```diff
@@             Coverage Diff             @@
##           master   #27046       +/-   ##
===========================================
+ Coverage   42.44%      92%   +49.55%     
===========================================
  Files         180      180               
  Lines       50399    50754      +355     
===========================================
+ Hits        21394    46695    +25301     
+ Misses      29005     4059    -24946
```

| Flag | Coverage Δ | |
|---|---|---|
| #multiple | `90.64% <100%> (?)` | |
| #single | `41.82% <0%> (-0.63%)` | :arrow_down: |

| [Impacted Files](https://codecov.io/gh/pandas-dev/pandas/pull/27046?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [pandas/io/json/normalize.py](https://codecov.io/gh/pandas-dev/pandas/pull/27046/diff?src=pr&el=tree#diff-cGFuZGFzL2lvL2pzb24vbm9ybWFsaXplLnB5) | `96.93% <100%> (+87.93%)` | :arrow_up: |
| [pandas/core/api.py](https://codecov.io/gh/pandas-dev/pandas/pull/27046/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvYXBpLnB5) | `100% <0%> (ø)` | :arrow_up: |
| [pandas/core/arrays/\_\_init\_\_.py](https://codecov.io/gh/pandas-dev/pandas/pull/27046/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvYXJyYXlzL19faW5pdF9fLnB5) | `100% <0%> (ø)` | :arrow_up: |
| [pandas/core/dtypes/generic.py](https://codecov.io/gh/pandas-dev/pandas/pull/27046/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvZHR5cGVzL2dlbmVyaWMucHk=) | `100% <0%> (ø)` | :arrow_up: |
| [pandas/api/types/\_\_init\_\_.py](https://codecov.io/gh/pandas-dev/pandas/pull/27046/diff?src=pr&el=tree#diff-cGFuZGFzL2FwaS90eXBlcy9fX2luaXRfXy5weQ==) | `100% <0%> (ø)` | :arrow_up: |
| [pandas/io/clipboard/\_\_init\_\_.py](https://codecov.io/gh/pandas-dev/pandas/pull/27046/diff?src=pr&el=tree#diff-cGFuZGFzL2lvL2NsaXBib2FyZC9fX2luaXRfXy5weQ==) | `54.34% <0%> (ø)` | :arrow_up: |
| [pandas/core/internals/\_\_init\_\_.py](https://codecov.io/gh/pandas-dev/pandas/pull/27046/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvaW50ZXJuYWxzL19faW5pdF9fLnB5) | `100% <0%> (ø)` | :arrow_up: |
| [pandas/\_typing.py](https://codecov.io/gh/pandas-dev/pandas/pull/27046/diff?src=pr&el=tree#diff-cGFuZGFzL190eXBpbmcucHk=) | `100% <0%> (ø)` | :arrow_up: |
| [pandas/core/index.py](https://codecov.io/gh/pandas-dev/pandas/pull/27046/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvaW5kZXgucHk=) | `100% <0%> (ø)` | :arrow_up: |
| [pandas/api/extensions/\_\_init\_\_.py](https://codecov.io/gh/pandas-dev/pandas/pull/27046/diff?src=pr&el=tree#diff-cGFuZGFzL2FwaS9leHRlbnNpb25zL19faW5pdF9fLnB5) | `100% <0%> (ø)` | :arrow_up: |
| ... and [144 more](https://codecov.io/gh/pandas-dev/pandas/pull/27046/diff?src=pr&el=tree-more) | |

------

[Continue to review full report at Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/27046?src=pr&el=continue).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/27046?src=pr&el=footer). Last update [c7d7e81...505a519](https://codecov.io/gh/pandas-dev/pandas/pull/27046?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).

@jreback Are you expecting tests to be added for this?
> @jreback Are you expecting tests to be added for this?

yep and / or perf benchmark
@jiangyue12392 do you have tests for this?
Thanks for the PR but somewhat unclear what this does. If you can add a test and / or performance benchmark feel free to ping and we can reopen to pick back up