2016-07-15 4 views
0

Ich erhalte diesen Fehler beim Versuch, diese JSON in Google BigQuery Tabelle Datei-00000000 zu importieren: JSON-Tabelle aufgetreten zu viele Fehler, aufgeben. Zeilen: 1; Fehler: 1. (Fehlercode: ungültig) JSON Parsing Fehler in Zeile beginnend bei Position 0 bei Datei: Datei-00000000. Start des Arrays ohne Start des Objekts. (Fehlercode: ungültig)JSON Formatierungsfehler

Dies ist die JSON

[{'instrument_token': 11192834, 'average_price': 8463.45, 'last_price': 8471.1, 'last_quantity': 75, 'buy_quantity': 1065150, 'volume': 5545950, 'depth': {'buy': [{'price': 8471.1, 'quantity': 300, 'orders': 131072}, {'price': 8471.0, 'quantity': 300, 'orders': 65536}, {'price': 8470.95, 'quantity': 150, 'orders': 65536}, {'price': 8470.85, 'quantity': 75, 'orders': 65536}, {'price': 8470.7, 'quantity': 225, 'orders': 65536}], 'sell': [{'price': 8471.5, 'quantity': 150, 'orders': 131072}, {'price': 8471.55, 'quantity': 375, 'orders': 327680}, {'price': 8471.8, 'quantity': 1050, 'orders': 65536}, {'price': 8472.0, 'quantity': 1050, 'orders': 327680}, {'price': 8472.1, 'quantity': 150, 'orders': 65536}]}, 'ohlc': {'high': 8484.1, 'close': 8336.45, 'low': 8422.35, 'open': 8432.75}, 'mode': 'quote', 'sell_quantity': 998475, 'tradeable': True, 'change': 1.6151959167271395}] 

http://jsonformatter.org/ auch Parse-Fehler für diesen JSON Block gibt. Brauchen Sie Hilfe zu verstehen, wo die Formatierung falsch ist - das ist die JSON von einem Rest API

+0

Vielleicht“, nicht" – doubleui

Antwort

6

Dies ist nicht gültig JSON. JSON verwendet doppelte Anführungszeichen, keine einfachen Anführungszeichen. Außerdem sollte Truetrue sein.

Wenn ich raten müsste, würde ich vermuten, dass dies Python-Code ist, der als JSON übergeben wird. :-)

Ich vermute, dass, selbst wenn dies in richtigen JSON gemacht wird, es nicht das Format ist, das Google BigQuery erwartet. Von https://cloud.google.com/bigquery/data-formats#json_format scheint es, dass Sie eine Textdatei mit einem JSON-Objekt pro Zeile haben sollten. Versuchen Sie, nur dieses:.

{"mode": "quote", "tradeable": true, "last_quantity": 75, "buy_quantity": 1065150, "depth": {"buy": [{"quantity": 300, "orders": 131072, "price": 8471.1}, {"quantity": 300, "orders": 65536, "price": 8471.0}, {"quantity": 150, "orders": 65536, "price": 8470.95}, {"quantity": 75, "orders": 65536, "price": 8470.85}, {"quantity": 225, "orders": 65536, "price": 8470.7}], "sell": [{"quantity": 150, "orders": 131072, "price": 8471.5}, {"quantity": 375, "orders": 327680, "price": 8471.55}, {"quantity": 1050, "orders": 65536, "price": 8471.8}, {"quantity": 1050, "orders": 327680, "price": 8472.0}, {"quantity": 150, "orders": 65536, "price": 8472.1}]}, "change": 1.6151959167271395, "average_price": 8463.45, "ohlc": {"close": 8336.45, "high": 8484.1, "open": 8432.75, "low": 8422.35}, "instrument_token": 11192834, "last_price": 8471.1, "sell_quantity": 998475, "volume": 5545950} 
+0

JSONformatter.org Fehler gibt sogar in doppelten Anführungszeichen meine bearbeiten –

+0

Siehe vor einer Sekunde nur – smarx

+0

@ChandanKumar: Aber im Grunde ist die Antwort: ** Das ist nicht JSON **, das war etwas, das du selbst leicht bestimmen konntest: Erstelle JSON nicht in Handarbeit, baue eine Struktur in welcher Sprache/Umgebung auch immer und benutze einen geeigneten JSON-Serializer, um den JSON zu erstellen: –