Closed aaltvater closed 5 years ago
So this is because its array-finding logic (which tries to determine what a "row" is, and is inherently imperfect) is finding this sub-object with an array in it and going with that:
"plan": [
{
"_id": "5b92dfd20cf0821f6cf47e0c",
"contractEffectiveDate": "1900-01-01T00:00:00.000Z",
"contractEndDate": null,
"startDate": "1900-01-01T00:00:00.000Z",
"endDate": "2043-09-07T20:30:10.819Z",
"anniversaryDate": "1900-01-01T00:00:00.000Z",
"percentage": 5.251,
"ratePlan": "5b92df900cf0821f6cf46c3b"
}
],
The logic for converting nested JSON hasn't changed, but it's possible that prior attempts to convert this JSON didn't have a sub-object like this, or was part of a larger array.
This only happens if the JSON given is itself for an object, not an array. If you want to convert the entire object as one giant row, then you should be able to work around this by putting the entire original JSON object inside of an array itself, by just surrounding the text with a {
and a }
.
Her'es what that looks like, and I verified it converted the object into one giant row with all fields:
[
{
"_id" : "5b92dfd20cf0821f6cf47e09",
"estimate" : {
"savingsData" : []
},
"priorityCodes" : [],
"someNumber" : 0,
"invoices" : [],
"primaryId" : 1155550373399,
"publicEnrollmentId" : null,
"accountNumber" : "TestAccount",
"sourceId" : "TestSource",
"foreignAccountNumber" : "99999999",
"subscriberNumber" : "999999999-7",
"source" : "TestSource",
"contactInformation" : {
"_id" : "5b92dfd20cf0821f6cf47e00",
"homePhone" : "9999999999",
"billingEmail" : "test@test.com",
"homePhoneDateLastUpdated" : "2018-09-07T20:30:10.851Z",
"cellPhoneDateLastUpdated" : "2018-09-07T20:30:10.851Z",
"businessPhoneDateLastUpdated" : "2018-09-07T20:30:10.851Z",
"otherPhoneDateLastUpdated" : "2018-09-07T20:30:10.851Z",
"homeEmailDateLastUpdated" : "2018-09-07T20:30:10.851Z",
"businessEmailDateLastUpdated" : "2018-09-07T20:30:10.852Z",
"billingEmailDateLastUpdated" : "2018-09-07T20:30:10.852Z",
"otherEmailDateLastUpdated" : "2018-09-07T20:30:10.852Z"
},
"nameOnBill" : "Testfirst Testlast",
"serviceAddress" : {
"line1" : "9999 Test Ave Ne",
"line2" : null,
"city" : "TestCity",
"county" : "",
"state" : "DC",
"zip" : "99999",
"zip4" : "",
"active" : true,
"createDate" : "2018-09-12T16:33:55.948Z",
"_id" : "5b994034900ffb31a23411b4"
},
"plan" : [
{
"_id" : "5b92dfd20cf0821f6cf47e0c",
"contractEffectiveDate" : "1900-01-01T00:00:00.000Z",
"contractEndDate" : null,
"startDate" : "1900-01-01T00:00:00.000Z",
"endDate" : "2043-09-07T20:30:10.819Z",
"anniversaryDate" : "1900-01-01T00:00:00.000Z",
"percentage" : 5.251,
"ratePlan" : "5b92df900cf0821f6cf46c3b"
}
],
"status" : "Accepted",
"somePlace" : "5b7da7ed8082c16fa169c82e",
"account" : "5b89b3b9c56fc06ee4cb12b3",
"propertyId" : "TestProperty",
"taxRate" : [],
"location" : [],
"leadTypeHistory" : [
{
"_id" : "5b9c1522d149ce5d43ddd18e",
"date" : "2018-09-14T20:08:02.441Z",
"value" : "Lead"
}
],
"statusHistory" : [
{
"_id" : "5b92dfd20cf0821f6cf47e0a",
"date" : "2018-09-07T20:30:10.851Z",
"value" : "Accepted"
}
],
"creditCheckResults" : [],
"archive" : [],
"planCode" : "Workbook-NCHYeiEFbMDRKyX39vkcH4PZTYaUk9WB",
"otherAccountID" : "TestOtherAccount",
"supplementalAccountId" : "TestSupplementalAccount",
"addressDateLastUpdated" : "2018-09-12T16:36:43.239Z",
"__v" : 1,
"leadType" : "Lead",
"bankLink" : "TestBankLink"
}
]
this is the valid JSON I would like to convert:
{ "_id" : "5b92dfd20cf0821f6cf47e09", "estimate" : { "savingsData" : [] }, "priorityCodes" : [], "someNumber" : 0, "invoices" : [], "primaryId" : 1155550373399, "publicEnrollmentId" : null, "accountNumber" : "TestAccount", "sourceId" : "TestSource", "foreignAccountNumber" : "99999999", "subscriberNumber" : "999999999-7", "source" : "TestSource", "contactInformation" : { "_id" : "5b92dfd20cf0821f6cf47e00", "homePhone" : "9999999999", "billingEmail" : "test@test.com", "homePhoneDateLastUpdated" : "2018-09-07T20:30:10.851Z", "cellPhoneDateLastUpdated" : "2018-09-07T20:30:10.851Z", "businessPhoneDateLastUpdated" : "2018-09-07T20:30:10.851Z", "otherPhoneDateLastUpdated" : "2018-09-07T20:30:10.851Z", "homeEmailDateLastUpdated" : "2018-09-07T20:30:10.851Z", "businessEmailDateLastUpdated" : "2018-09-07T20:30:10.852Z", "billingEmailDateLastUpdated" : "2018-09-07T20:30:10.852Z", "otherEmailDateLastUpdated" : "2018-09-07T20:30:10.852Z" }, "nameOnBill" : "Testfirst Testlast", "serviceAddress" : { "line1" : "9999 Test Ave Ne", "line2" : null, "city" : "TestCity", "county" : "", "state" : "DC", "zip" : "99999", "zip4" : "", "active" : true, "createDate" : "2018-09-12T16:33:55.948Z", "_id" : "5b994034900ffb31a23411b4" }, "plan" : [ { "_id" : "5b92dfd20cf0821f6cf47e0c", "contractEffectiveDate" : "1900-01-01T00:00:00.000Z", "contractEndDate" : null, "startDate" : "1900-01-01T00:00:00.000Z", "endDate" : "2043-09-07T20:30:10.819Z", "anniversaryDate" : "1900-01-01T00:00:00.000Z", "percentage" : 5.251, "ratePlan" : "5b92df900cf0821f6cf46c3b" } ], "status" : "Accepted", "somePlace" : "5b7da7ed8082c16fa169c82e", "account" : "5b89b3b9c56fc06ee4cb12b3", "propertyId" : "TestProperty", "taxRate" : [], "location" : [], "leadTypeHistory" : [ { "_id" : "5b9c1522d149ce5d43ddd18e", "date" : "2018-09-14T20:08:02.441Z", "value" : "Lead" } ], "statusHistory" : [ { "_id" : "5b92dfd20cf0821f6cf47e0a", "date" : "2018-09-07T20:30:10.851Z", "value" : "Accepted" } ], "creditCheckResults" : [], "archive" : [], "planCode" : "Workbook-NCHYeiEFbMDRKyX39vkcH4PZTYaUk9WB", "otherAccountID" : "TestOtherAccount", "supplementalAccountId" : "TestSupplementalAccount", "addressDateLastUpdated" : "2018-09-12T16:36:43.239Z", "__v" : 1, "leadType" : "Lead", "bankLink" : "TestBankLink" } this is the result: _id,contractEffectiveDate,contractEndDate,startDate,endDate,anniversaryDate,percentage,ratePlan 5b92dfd20cf0821f6cf47e0c,1900-01-01T00:00:00.000Z,,1900-01-01T00:00:00.000Z,2043-09-07T20:30:10.819Z,1900-01-01T00:00:00.000Z,5.251,5b92df900cf0821f6cf46c3b