Error importing JSON file in Parse - json

My current file looks like this:
{
"result": [
{
"Longitude" : "-075.947332",
"Zipcode" : "21922",
"ZipClass" : "STANDARD",
"County" : "CECIL",
"City" : "ELKTON",
"State" : "MD",
"Latitude" : "+39.593612"
},
{
"Longitude" : "-075.884544",
"Zipcode" : "21930",
"ZipClass" : "PO BOX ONLY",
"County" : "CECIL",
"City" : "GEORGETOWN",
"State" : "MD",
"Latitude" : "+39.366183"
}
]
}
I continuously get the following error:
file should have the following format
{ "results": [ {...}, ... ]}
Any ideas whats going on or how I can import my file.
The link to my file is right here for further understanding: http://gomashup.com/json.php?fds=geo/usa/zipcode/state/MD&jsoncallback=?
Note* (There is no "?" in my JSON file like data in above link.)

Looks like you need to change "result" to "results".
The file you linked to begins with a parenthesis ((), that might be an issue too.

Related

How to add number as firebase realtime database child without converting to array?

I want to make a DB structure like the following:
But it just converts the whole object to an array.
Here's what I get when I export this JSON.
[ null, {
"oPNfOlBcS4gl3rvZ4CIme9MDk0p1" : {
"added_at" : 1647966583316,
"city" : "Test",
"country" : "Test",
"name" : "Test",
"state" : "Test",
"uid" : "oPNfOlBcS4gl3rvZ4CIme9MDk0p1"
}
}, {
"oPNfOlBcS4gl3rvZ4CIme9MDk0p1" : {
"added_at" : 1647966583316,
"city" : "Test",
"country" : "Test",
"name" : "Test",
"state" : "Test",
"uid" : "oPNfOlBcS4gl3rvZ4CIme9MDk0p1"
}
} ]
I tried keeping the first child as 1 and the second as "first" (or some random string) and exported JSON and here's what I got...
{
"1" : {
"oPNfOlBcS4gl3rvZ4CIme9MDk0p1" : {
"added_at" : 1647966583316,
"city" : "Test",
"country" : "Test",
"name" : "Test",
"state" : "Test",
"uid" : "oPNfOlBcS4gl3rvZ4CIme9MDk0p1"
}
},
"first" : {
"oPNfOlBcS4gl3rvZ4CIme9MDk0p1" : {
"added_at" : 1647966583316,
"city" : "Test",
"country" : "Test",
"name" : "Test",
"state" : "Test",
"uid" : "oPNfOlBcS4gl3rvZ4CIme9MDk0p1"
}
}
}
I want something similar, but with children like "1", "2" instead.
Is it possible? Or using children like "first", "second" is the only solution right now?
When you read a node with sequential numeric keys (as in your screenshot and first JSON example), the Firebase SDK (and REST) API) automatically coerce that data to an array. There is no way to configure this behavior.
If you don't want the array coercion you should use non-numeric keys. My common approach is to prefix each key with a short string, like "key1", "key2", etc.
Also see: Best Practices: Arrays in Firebase.

Autodesk ATF-1008 Error

I am getting an ATF-1008 error which has no explanation when translating files that previously worked fine. What does the ATF-1008 error mean?
{
"guid" : "dXJuOmFkc2sub2JqZWN0czpvcy5vYmplY3Q6c3RlbW4vNTkxY2U3NzAzNzFhMjEwMmM3MWQwMTgzLWZ3bGMza2x2ODBvNGN0bXZjMm94c3djZGkuaXB0",
"success" : "0%",
"hasThumbnail" : "false",
"progress" : "complete",
"urn" : "dXJuOmFkc2sub2JqZWN0czpvcy5vYmplY3Q6c3RlbW4vNTkxY2U3NzAzNzFhMjEwMmM3MWQwMTgzLWZ3bGMza2x2ODBvNGN0bXZjMm94c3djZGkuaXB0",
"status" : "failed",
"startedAt" : "Thu May 18 05:29:50 UTC 2017",
"region" : "US",
"owner" : "dXJuOmFkc2sub2JqZWN0czpvcy5vYmplY3Q6c3RlbW4vNTkxY2U3NzAzNzFhMjEwMmM3MWQwMTgzLWZ3bGMza2x2ODBvNGN0bXZjMm94c3djZGkuaXB0",
"type" : "design",
"children" : [
{
"guid" : "aa85aad6-c480-4a35-9cbf-4cf5994a25ba",
"messages" : [
{
"type" : "error",
"code" : "ATF-1008",
"message" : [
"Error: {0}",
"C:\\worker\\viewing-inventor-lmv\\tmp\\job-1\\264\\591ce770371a2102c71d0183-fwlc3klv80o4ctmvc2oxswcdi.ipt"
]
}
],
"hasThumbnail" : "false",
"role" : "viewable",
"version" : "2.0",
"progress" : "complete",
"urn" : "dXJuOmFkc2sub2JqZWN0czpvcy5vYmplY3Q6c3RlbW4vNTkxY2U3NzAzNzFhMjEwMmM3MWQwMTgzLWZ3bGMza2x2ODBvNGN0bXZjMm94c3djZGkuaXB0",
"status" : "success",
"type" : "folder"
}
]
}
I found that the file had become corrupt after uploading to Forge OSS without supplying a Content-Length header. After attempting to convert this file I would get this error. By inspecting the original file contents I was able to see the file had not uploaded as expected.

Push data in json array MongoDB

I have the following structure in my mondoDB:
"source" : [
{
"source_id" : "800000021",
"source" : "Test1"
}
]
"state" : "AM",
"owner_phone" : "0",
"latitude" : 0,
"leedon_activated" : "True",
"zip_code" : "12345",
"fax" : "0",
I want to add another json to the source array for the following resut:
"source" : [
{
"source_id" : "800000021",
"source" : "Test1"
},
{
"source_id" : "800000022",
"source" : "Test2"
}
]
"state" : "AM",
"owner_phone" : "0",
"latitude" : 0,
"leedon_activated" : "True",
"zip_code" : "12345",
"fax" : "0"
What will be MongoDB query for it?
Read about $push here
Your code will something like this
yourmodelname.update({ /* some conditions to updating files */ },{$push: {"source": {"source_id" : "213123", "source" : "asdasd"}}})

Apex JSON parsing error

I am getting the following error in my code:
System.JSONException null Don't know the type of the Apex object to
deserialize at [line:1, column:1] 11 (System Code)
Class.FactorLab.FactorLabWebservices.RetrieveUsersFromFactorLab: line
60, column 1 Class.FactorLab.PullUsers.execute: line 61, column 1
Here is the code in question:
public static List<FactorLabPullUser> RetrieveUsersFromFactorLab(List<String> ids){
HttpRequest req = getHttpRequest(baseUrl + '/ws/sfdc/people/retrieve', 'POST');
req.setBody(JSON.serialize(ids));
req.setHeader('Content-Type', 'application/json');
if(Test.isRunningTest()){
return null;
}
HttpResponse res = sendRequest(req);
// This is the line with the error
List<FactorLabPullUser> flusers = (List<FactorLabPullUser>)JSON.deserialize(res.getBody(), Type.forname('List<FactorLabPullUser>'));
return flusers;
}
I'm sure that it's receiving valid JSON, but I'm not sure the exact JSON it's receiving when it gets this error. It could simply get an empty array:
[]
It could also get something like this:
[ { "SFDCStatus" : "RETRIEVED",
"address" : "123 Fake St.",
"addressLine1" : "Address1",
"addressLine2" : "Address2",
"city" : "San Francisco",
"companyName" : "Big Cheese, Inc.",
"deleted" : false,
"email" : "james.willard#fake.com",
"firstName" : "James",
"hireDate" : "2000-04-15T00:00:00Z",
"id" : 39,
"lastName" : "Willard",
"lastUpdated" : "2011-11-23T05:44:03Z",
"myersBriggs" : "SFDC",
"name" : "James Willard",
"phone" : "415-555-1212",
"position" : "Big Chief",
"regions" : [ { "deleted" : false,
"id" : 445,
"name" : "Mountain"
} ],
"state" : "CA",
"yearsExp" : 20.0,
"zip" : "94131"
},
{ "SFDCStatus" : "RETRIEVED",
"deleted" : false,
"firstName" : "Daniel",
"id" : 40,
"lastName" : "Adams",
"lastUpdated" : "2011-11-23T05:44:03Z",
"name" : "Daniel Adams"
}
]
Any ideas? Someone told me this was a Salesforce.com bug, but it seems like even if that were true, there must be a workaround.
Looks like you may not be casting properly. I haven't played around with the serialize/deserialize native JSON much yet and have preferred to do my own parsing/persisting. But your line causing the error looks suspicious:
List<FactorLabPullUser> flusers = (List<FactorLabPullUser>)JSON.deserialize(res.getBody(), Type.forname('List<FactorLabPullUser>'));
I think it should look like the following:
List<FactorLabPullUser> flusers = (List<FactorLabPullUser>)JSON.deserialize(res.getBody(), List<FactorLabPullUser>.class);
I can't see for sure from your code snippit but if the FactorLabPullUser class is an inner class you will need to fully qualify it for Type.forName() to work.
I would expect to see something like this:
List<FactorLabPullUser> flusers = (List<FactorLabPullUser>)JSON.deserialize(res.getBody(), Type.forname('List<Outerclass.FactorLabPullUser>'));
I think that the bug you mention is to do with the use of the .class method - I have noticed this not always return a valid Type.

How to add Timestamp to Spring-Data-Mongo in Roo?

I have a Spring Roo project I am trying to create based on log4mongo-java appender and I want to get access to the data entries that looks like:
{
"_id" : ObjectId("4f16cd30b138685057c8ebcb"),
"timestamp" : ISODate("2012-01-18T13:46:24.704Z"),
"level" : "INFO", "thread" : "catalina-exec-8180-3",
"message" : "method execution[execution(TerminationComponent.terminateCall(..))]",
"loggerName" :
{ "fullyQualifiedClassName" : "component_logger",
"package" : ["component_logger"],
"className" : "component_logger"
},
"properties" : {
"cookieId" : "EDE44DC03EB65D91657885A34C80595E"
},
"fileName" : "LoggingAspect.java",
"method" : "logForComponent",
"lineNumber" : "81", "class" : {
"fullyQualifiedClassName" : "com.comcast.ivr.core.aspects.LoggingAspect",
"package" : ["com", "comcast", "ivr", "core", "aspects", "LoggingAspect"],
"className" : "LoggingAspect"
},
"host" : {
"process" : "2220#pacdcivrqaapp01",
"name" : "pacdcivrqaapp01",
"ip" : "24.40.31.85"
},
"applicationName" : "D2",
"eventType" : "Development"
}
The timestamp looks like:
"timestamp" : ISODate("2012-01-17T22:30:19.839Z")
How can I add a field in my Logging domain object to map this field?
That's just the JavaScript Date (according to the mongo docs, and as can be demonstrated in the shell), so try with java.util.Date.