RicoSuter/VisualJsonEditor

Unable to cast object of type 'Newtonsoft.Json.Linq.JObject' to type 'Newtonsoft.Json.Linq.JValue'.

deaquino opened this issue · 3 comments

I have an object with multiple properties (all of them the same type)

at VisualJsonEditor.Models.JsonObjectModel.FromJson(JObject obj, JsonSchema4 schema) in \src\VisualJsonEditor\Models\JsonObjectModel.cs:line 98
at VisualJsonEditor.Models.JsonObjectModel.FromJson(String jsonData, JsonSchema4 schema) in \src\VisualJsonEditor\Models\JsonObjectModel.cs:line 62
at VisualJsonEditor.Models.JsonDocumentModel.<>c__DisplayClass28_0.b__0() in \src\VisualJsonEditor\Models\JsonDocumentModel.cs:line 120
at System.Threading.Tasks.Task`1.InnerInvoke()
at System.Threading.Tasks.Task.Execute()

Can you provide a sample schema?

These are the files that are causing the exception.

Thank you!

{
  "Activities": {
    "Enabled": true,
    "InvokeMode": "Watcher",
    "Area": "Activities",
    "CsvSettings": {
      "Delimiter": ";",
      "DateFormat": "yyyy-MM-dd'T'HH:mm:ss'Z'",
      "Headers": {
        "HasHeaders": true,
        "CustomHeaders": [
          "ActivityId",
          "StartDate",
          "EndDate"
        ]
      },
      "Trim": true,
      "BatchSleep": "00:00:00",
      "BatchSize": null,
      "MaxFileErrors": null
    },
    "ExcelSettings": null,
    "ExecutionSettings": {
      "Attempts": 3,
      "SleepInterval": "00:00:05"
    },
    "MappingSettings": {
      "InitFunction": "Activities.GetActivity(Property[ActivityId])",
      "Property[StartDate]": "Property[StartDate]",
      "Property[EndDate]": "Property[EndDate]",
    }
  }
}
{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "title": "InterfacesSettings",
  "additionalProperties": false,
  "properties": {
    "Activities": {
      "oneOf": [
        {
          "$ref": "#/definitions/InterfaceSettings"
        },
        {
          "type": "null"
        }
      ]
    },
    "Telemetry": {
      "oneOf": [
        {
          "$ref": "#/definitions/InterfaceSettings"
        },
        {
          "type": "null"
        }
      ]
    },
    "Gis": {
      "oneOf": [
        {
          "$ref": "#/definitions/InterfaceSettings"
        },
        {
          "type": "null"
        }
      ]
    },
    "WorkOrders": {
      "oneOf": [
        {
          "$ref": "#/definitions/InterfaceSettings"
        },
        {
          "type": "null"
        }
      ]
    },
    "Billing": {
      "oneOf": [
        {
          "$ref": "#/definitions/InterfaceSettings"
        },
        {
          "type": "null"
        }
      ]
    }
  },
  "definitions": {
    "InterfaceSettings": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "Enabled": {
          "type": "boolean"
        },
        "InvokeMode": {
          "oneOf": [
            {
              "$ref": "#/definitions/FileInvokeMode"
            }
          ]
        },
        "Area": {
          "type": [
            "null",
            "string"
          ]
        },
        "CsvSettings": {
          "oneOf": [
            {
              "$ref": "#/definitions/CsvSettings"
            },
            {
              "type": "null"
            }
          ]
        },
        "ExcelSettings": {
          "oneOf": [
            {
              "$ref": "#/definitions/ExcelSettings"
            },
            {
              "type": "null"
            }
          ]
        },
        "ExecutionSettings": {
          "oneOf": [
            {
              "$ref": "#/definitions/ProviderExecutionSettings"
            },
            {
              "type": "null"
            }
          ]
        },
        "MappingSettings": {
          "type": [
            "null",
            "object"
          ],
          "additionalProperties": {
            "type": "string"
          }
        }
      }
    },
    "FileInvokeMode": {
      "type": "string",
      "x-enumNames": [
        "Watcher",
        "Live",
        "Nightly",
        "None"
      ],
      "enum": [
        "Watcher",
        "Live",
        "Nightly",
        "None"
      ],
      "description": ""
    },
    "CsvSettings": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "Delimiter": {
          "type": [
            "null",
            "string"
          ]
        },
        "DateFormat": {
          "type": [
            "null",
            "string"
          ]
        },
        "Headers": {
          "oneOf": [
            {
              "$ref": "#/definitions/FileHeadersSettings"
            },
            {
              "type": "null"
            }
          ]
        },
        "Trim": {
          "type": "boolean"
        },
        "BatchSleep": {
          "type": [
            "null",
            "string"
          ],
          "format": "time-span"
        },
        "BatchSize": {
          "type": [
            "integer",
            "null"
          ],
          "format": "int32"
        },
        "MaxFileErrors": {
          "type": [
            "integer",
            "null"
          ],
          "format": "int32"
        }
      }
    },
    "FileHeadersSettings": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "HasHeaders": {
          "type": "boolean"
        },
        "CustomHeaders": {
          "type": [
            "array",
            "null"
          ],
          "items": {
            "type": "string"
          }
        }
      }
    },
    "ExcelSettings": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "Headers": {
          "oneOf": [
            {
              "$ref": "#/definitions/FileHeadersSettings"
            },
            {
              "type": "null"
            }
          ]
        },
        "Trim": {
          "type": "boolean"
        },
        "BatchSleep": {
          "type": [
            "null",
            "string"
          ],
          "format": "time-span"
        },
        "BatchSize": {
          "type": [
            "integer",
            "null"
          ],
          "format": "int32"
        },
        "MaxFileErrors": {
          "type": [
            "integer",
            "null"
          ],
          "format": "int32"
        }
      }
    },
    "ProviderExecutionSettings": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "Attempts": {
          "type": "integer",
          "format": "int32"
        },
        "SleepInterval": {
          "type": "string",
          "format": "time-span"
        }
      }
    }
  }
}

fixed with e66f761, v2.0