I'm new to Postman- I am inserting a report and calling this function with a POST and Body JSON like this:
{
"data": [
{
prmRoadClosures : "I-65",
prmFirstMaintainStart=: "Test_EMS",
prmPSR_AbnormalOperations: "Test AO",
prmFeedstockChanges: "Test FSC",
prmLineupChanges: "Test LC",
prmSafetyMeetings: "Test_SM",
prmAR_SH_ID: 1,
prmAR_RE_ID : 1,
prmCR_AbnormalOperations : "Test AO",
prmHighPriorityAlarms : "Test HPA",
prmImpairment_to_fire_protection_systems : "Test Fire systems",
prmAlarmsInhibited : "test ALARMS",
prmCR_OP_ID : 1,
prmCR_PC_ID : 1,
prmFR_AbnormalOperations : "Test AO",
prmMaintenance : "test M",
prmFR_OP_ID : "1",
prmBP_ID : 1,
prmDP_ID : 1,
prmEQM_ID : 1,
prmCreatedDate : ,
prmUpdatedDate : ,
prmCreatedBy : "HS",
prmUpdatedBy : "HS",
prmShift : "1",
prmArea_ID : 1,
prmUser_ID : 1
}
]
}
the Bad Script error show
prmRoadClosures : "I-65",
to be the offending line. I can't see why I'm getting this error. Is it obvious?
TIA
Harry
That's not JSON Format like previously said.
If you have doubt on json format, you can use a validator like : https://jsonformatter.curiousconcept.com/
It will find error for each row so that's really helpful to find all mistakes.
Related
I have this JSON:
{
"totalMemory" : 12206567424,
"totalProcessors" : 4,
"version" : "0.4.1",
"agent" : {
"reconnectRetrySec" : 5,
"agentName" : "1001",
"checkRecovery" : false,
"backPressure" : 10000,
"throttler" : 100
},
"logPath" : "/eq/equalum/eqagent-0.4.1.0-SNAPSHOT/logs",
"startTime" : 1494837249902,
"status" : {
"current" : "active",
"currentMessage" : null,
"previous" : "pending",
"previousMessage" : "Recovery:Starting pipelines"
},
"autoStart" : false,
"recovery" : {
"agentName" : "1001",
"partitionInfo" : { },
"topicToInitialCapturePosition" : { }
},
"sources" : [ {
"dataSource" : "oracle",
"name" : "oracle_source",
"captureType" : "directOverApi",
"streams" : [ ],
"idlePollingFreqMs" : 100,
"status" : {
"current" : "active",
"currentMessage" : null,
"previous" : "pending",
"previousMessage" : "Trying to init storage"
},
"host" : "192.168.191.5",
"metricsType" : { },
"bulkSize" : 10000,
"user" : "STACK",
"password" : "********",
"port" : 1521,
"service" : "equalum",
"heartbeatPeriodInMillis" : 1000,
"lagObjective" : 1,
"dataSource" : "oracle"
} ],
"upTime" : "157 min, 0 sec",
"build" : "0-SNAPSHOT",
"target" : {
"targetType" : "equalum",
"agentID" : 1001,
"engineServers" : "192.168.56.100:9000",
"kafkaOptions" : null,
"eventsServers" : "192.168.56.100:9999",
"jaasConfigurationPath" : null,
"securityProtocol" : "PLAINTEXT",
"stateMonitorTopic" : "_state_change",
"targetType" : "equalum",
"status" : {
"current" : "active",
"currentMessage" : null,
"previous" : "pending",
"previousMessage" : "Recovery:Starting pipelines"
},
"serializationFormat" : "avroBinary"
}
}
I trying using Jmeter to extract out the value of agentID, how can I do that using Jmeter, what would be better ? using extractor or json extractor?
what I am trying to do is to extract agentID value in order to use it on another http request sample, but first I have to extract it from this request.
thanks!
I believe using JSON Extractor is the best way to get this agentID value, the relevant JsonPath query will be as simple as $..agentID
Demo:
See the following reference material:
JsonPath - Getting Started - for initial information regarding JsonPath language, functions, operators, etc.
JMeter's JSON Path Extractor Plugin - Advanced Usage Scenarios - for more complex scenarios.
My collection has document like this
{
"_id" : ObjectId("587c8d0364b6e32706f7edef"),
"first_name" : "John",
"last_name" : "Doe",
"password" : "aasdjsabb12213b21bbcghc1h2",
"shift" : "A",
"dept" : "Management"
"Requests" : [
{
"weekId" : 1,
"MO" : 1,
"TU" : 2,
"W" : 3,
"TH" : 9,
"FR" : 10,
"SA" : 6,
"SU" : 1
}
]
}
I want to export the result of my query to csv and need fields flattened out like this
{
"_id" : ObjectId("587c8d0364b6e32706f7edef"),
"first_name" : "John",
"last_name" : "Doe",
"password" : "aasdjsabb12213b21bbcghc1h2",
"shift" : "A",
"dept" : "Management"
"weekId" : 1,
"MO" : 1,
"TU" : 2,
"W" : 3,
"TH" : 9,
"FR" : 10,
"SA" : 6,
"SU" : 1
}
I am trying to use aggregate function but to no avail. Can anyone suggest me how to do this?
This is my working code but I don't think this is the right way
db.req.aggregate([{$unwind:'$Requests'},{$project: {first_name:1,last_name:1,dept:1,"WeekId":"$Requests.weekdId","Mon":"$Requests.MO","Tue":"$Requests.TU","Wed":"$Requests.W","Thu":"$Requests.TH","Fri":"$Requests.FR","Sat":"$Requests.SA","Sun":"$Requests.SU"}},{$out:"results"}]);
You can do this with an aggregate query, but its not very pretty:
db.test.aggregate([
{$unwind:"$Requests"},
{$project:
{_id:1,
first_name:1,
last_name:1,
password:1,
shift:1,
dept:1,
weekId:"$Requests.weekId",
MO:"$Requests.MO",
TU:"$Requests.TU",
W:"$Requests.W",
TH:"$Requests.TH",
FR:"$Requests.FR",
SA:"$Requests.SA",
SU:"$Requests.SU"}}])
.pretty()
So basically unwind the Requests array, then project out the document you want to produce. Hope this makes sense.
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.
[
{
"id" : 1,
"name" : "clevin",
"description" : "Version 1 : some desc",
"info" : [{
"id" : 2,
"name" : "abc",
"size" : "5 GB",
"used" : "25%"
},
{
"id" : 3,
"name" : "def",
"size" : "10 GB",
"used" : "15%"
},
{
"id" : 4,
"name" : "ghi",
"size" : "20 GB",
"used" : "5%"
}],
}]
This is my json file. When ever i mouse over "info.name"[abc, def, ghi] popover will display "name", "size" and "used".
but my issue is "abc" is the first value , when ever i mouseover it display value as expected. but when i mouseover "def" and "ghi" nothing is happened :(.
<ul type="none">
<li>
<label id="vol-label" class="muted">Info :</label>
{{#info}}
<span id="value"><a><u>{{name}}</u></a></span>
<span id="info-popover-title" class="hide">{{name}}</span>
<div id="info-popover-content" class="hide">
<p>Size : {{size}}</p> <p> Used : {{used}}</p><p> Status : {{status}}</p>
</div>
{{/info}}
</li>
</ul>
This is my template(mustache).
following is my view part(backbone.js)
events: {
"mouseenter #value" : "showDetails",
"mouseleave #value" : "hideDetails" ,
},
showDetails : function() {
this.$("#value").popover({
html : true,
title: function() {
return $("#info-popover-title").html();
},
content: function() {
return $("#info-popover-content").html();
}
});
this.$("#value").popover('show');
},
hideDetails : function() {
this.$("#value").popover('hide');
},
Please see my both screen shot to understand the issue. In fist screens hot see am getting all json info values "abc" "def" and "ghi" . in 2nd screen shot if i mouse over am getting "abc" values. but "def" and "ghi" value is not at all displaying. am not figure it out what is the issue :(.
I need to popove "def" and "ghi" values also. But i think something is wrong in my logic. Thanks in advance. This is really a rare issue for me might be others also.
If i use class insted of id following is the screen shot :(
2 things that you need to change here. First, is to use class to define for popovers instead of id. And the second is to abstract each <li> into its own view. Currently, you have one view that loops through the entire collection. All your events are currently tied to this one view. Doing those things I mentioned should fix this issue.
You can do something like this to have the become its own view which carries it's own sub-element. Just wrote this quickly and haven't tested but the idea is something like this. I'm not really sure which popover library you're using but the idea is generally the same.
Edit: Didn't realized you were using Mustache/Handlebars, so here's the JS Fiddle. Code
Now if you try to call each object it should work.
var abc =
{
"id" : 1,
"name" : "clevin",
"description" : "Version 1 : some desc",
"info" : {
"id" : 2,
"name" : "abc",
"size" : "5 GB",
"used" : "25%"
}
};
var def =
{
"id" : 3,
"name" : "def",
"size" : "10 GB",
"used" : "15%"
};
var ghi = {
"id" : 4,
"name" : "ghi",
"size" : "20 GB",
"used" : "5%"
};
var output =
{
show : function()
{
return abc["info"];
}
};
console.log(output.show());
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.