Repository: googleapis/google-cloud-python

Issue:
BigQuery: "Failed to parse JSON: No active field found" when using load_table_from_json()
On Mac (Python 3.7.4 & google-cloud-bigquery==1.19.0) I'm using the following code:

```
from google.cloud import bigquery

test_ndjson = '{"name": "bob"}'
client = bigquery.Client()
table_ref = client.dataset('my_ds').table('test')
job_config = bigquery.LoadJobConfig()
job_config.write_disposition = bigquery.WriteDisposition.WRITE_TRUNCATE
job_config.source_format = bigquery.SourceFormat.NEWLINE_DELIMITED_JSON
job_config.autodetect = True
job = client.load_table_from_json(test_ndjson, table_ref, job_config=job_config)
job.result()  # Waits for table load to complete.
```
I get:
> google.api_core.exceptions.BadRequest: 400 Error while reading data, error message: Failed to parse JSON: No active field found.; ParsedString returned false

When I do exactly the same thing using the bq command it works as expected:
```
echo '{"name": "bob"}' > data.json
bq load --apilog '' --source_format=NEWLINE_DELIMITED_JSON --autodetect=True myproject\:my_ds.test ./data.json
```



Discussion:
Confirmed, I was able to reproduce the issue with the posted code (thanks @jacques- ).
Actually, the type of `test_ndjson` is incorrect. It should be an iterable of dictionaries ([docs](https://googleapis.github.io/google-cloud-python/latest/bigquery/generated/google.cloud.bigquery.client.Client.html#google.cloud.bigquery.client.Client.load_table_from_json)). Changing `test_ndjson` to the following will work:
```py
test_ndjson = [{"name": "bob"}]
```

@tswast I suppose it is reasonable to expect that passing in a JSON string to the method should work, too - let's add support for that?
(re-classifying as feature request, and will update the description if confirmed)
This feels a bit redundant with the `load_table_from_file` method, since really we just want to pass the bytes through to the resumable upload in this case. Maybe we need a `load_table_from_string` / `load_table_from_bytes` method?
Have there been feature requests for this in the past?
Not sure if we really need a `*_from_string` version of the method, since it is straightforward to wrap string data into a binary file-like object, and pass it to `load_table_from_file()`...
I agree that `*_from_string` is probably not necessary. A few code samples on how to wrap a string in a BytesIO / StringIO object would likely suffice.

Resolving patch:
diff --git a/bigquery/google/cloud/bigquery/client.py b/bigquery/google/cloud/bigquery/client.py
--- a/bigquery/google/cloud/bigquery/client.py
+++ b/bigquery/google/cloud/bigquery/client.py
@@ -1644,6 +1644,22 @@ def load_table_from_json(
             json_rows (Iterable[Dict[str, Any]]):
                 Row data to be inserted. Keys must match the table schema fields
                 and values must be JSON-compatible representations.
+
+                .. note::
+
+                    If your data is already a newline-delimited JSON string,
+                    it is best to wrap it into a file-like object and pass it
+                    to :meth:`~google.cloud.bigquery.client.Client.load_table_from_file`::
+
+                        import io
+                        from google.cloud import bigquery
+
+                        data = u'{"foo": "bar"}'
+                        data_as_file = io.StringIO(data)
+
+                        client = bigquery.Client()
+                        client.load_table_from_file(data_as_file, ...)
+
             destination (Union[ \
                 :class:`~google.cloud.bigquery.table.Table`, \
                 :class:`~google.cloud.bigquery.table.TableReference`, \


Test patch: