@lingk/sync 2.2.6 → 2.2.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -5404,6 +5404,7 @@ module.exports =
5404
5404
  var _this = _possibleConstructorReturn(this, (FlatFile.__proto__ || Object.getPrototypeOf(FlatFile)).call(this));
5405
5405
 
5406
5406
  _this.parseJsonFile = function (content, file) {
5407
+ console.log("content", content);
5407
5408
  // READ THE JSON
5408
5409
  var json = void 0;
5409
5410
  try {
@@ -5413,19 +5414,39 @@ module.exports =
5413
5414
  }
5414
5415
  if (json) {
5415
5416
  var fields = [];
5416
- json.forEach(function (row) {
5417
- Object.keys(row).forEach(function (col) {
5418
- if (!fields.find(function (f) {
5419
- return f.label === col;
5420
- })) {
5421
- fields.push({
5422
- label: col,
5423
- name: col,
5424
- type: row[col] && _typeof(row[col])
5417
+ try {
5418
+ var isArray = Array.isArray(json);
5419
+ if (isArray) {
5420
+ json.forEach(function (row) {
5421
+ Object.keys(row).forEach(function (col) {
5422
+ if (!fields.find(function (f) {
5423
+ return f.label === col;
5424
+ })) {
5425
+ fields.push({
5426
+ label: col,
5427
+ name: col,
5428
+ type: row[col] && _typeof(row[col])
5429
+ });
5430
+ }
5425
5431
  });
5426
- }
5427
- });
5428
- });
5432
+ });
5433
+ } else {
5434
+ Object.keys(json).forEach(function (col) {
5435
+ if (!fields.find(function (f) {
5436
+ return f.label === col;
5437
+ })) {
5438
+ fields.push({
5439
+ label: col,
5440
+ name: col,
5441
+ type: json[col] && _typeof(json[col])
5442
+ });
5443
+ }
5444
+ });
5445
+ }
5446
+ } catch (e) {
5447
+ _this.setState({ dropError: e });
5448
+ }
5449
+
5429
5450
  var meta = {
5430
5451
  name: file.name,
5431
5452
  type: file.name.substr(0, file.name.lastIndexOf(".")).split(" ").join(""),
@@ -5641,7 +5662,6 @@ module.exports =
5641
5662
  var Spinner = inputs.Spinner;
5642
5663
  var Modal = inputs.Modal;
5643
5664
  var hasFile = meta && meta.length > 0;
5644
-
5645
5665
  var fileSchema = [];
5646
5666
  var fileSchemaNames = [];
5647
5667
  this.props.fileSchema && this.props.fileSchema.forEach(function (f) {