是否可以从Grunt任务中启动MongoDB?基本上当我运行我的开发环境时,grunt server
我希望它可以通过运行来启动MongoDB服务器mongod
.
我有一些JSON数据,如下所示:
{
"response":{
"_token":"StringValue",
"code":"OK",
"user":{
"userid":"2630944",
"firstname":"John",
"lastname":"Doe",
"reference":"999999999",
"guid":"StringValue",
"domainid":"99999",
"username":"jdoe",
"email":"jdoe@jdoe.edu",
"passwordquestion":"",
"flags":"0",
"lastlogindate":"2013-02-05T17:54:06.31Z",
"creationdate":"2011-04-15T14:40:07.22Z",
"version":"3753",
"data":{
"aliasname":{
"$value":"John Doe"
},
"smsaddress":{
"$value":"5555555555@messaging.sprintpcs.com"
},
"blti":{
"hideemail":"false",
"hidefullname":"false"
},
"notify":{
"grades":{
"$value":"0"
},
"messages":{
"$value":"1"
}
},
"beta_component_courseplanexpress_1":{
"$value":"true"
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
我正在使用C#和JSON.NET来解析数据.我已经能够使用这种算法成功获取数据:
User MyUser = new User();
JToken data = JObject.Parse(json);
MyUser.FirstName = (string) data.SelectToken("response.user.firstname");
//The same for all the other properties.
Run Code Online (Sandbox Code Playgroud)
问题在于该data
领域.该字段主要基于用户首选项,并且仅在使用时插入数据.这些字段都是自定义的,开发人员可以无限制地放入任意数量的字段.从本质上讲,它是所有自由格式数据.另外正如您所注意到的那样,它们可以与数据嵌套得非常远.
我试过跑:
MyUser.Data = JsonConvert.DeserializeObject<List<JToken>>((string) data.SelectToken("response.user.data");
Run Code Online (Sandbox Code Playgroud)
这不起作用.
您如何将其转换为在C#对象中使用?
我在Angular服务中使用此代码: -
var formData = function (data) {
var fd = new FormData();
angular.forEach(data, function (value, key) {
fd.append(key, value);
});
return fd;
}
var updateUserPic = function (profilePic, callback, userId) {
var userId = userId || FRAME_API.proxyUserId; // jshint ignore:line
if (!_.isFunction(callback)) {
throw new Error('You must provide a callback function.');
}
$http({
method: 'POST',
url: '/Learn/PostUserProfile.ashx?action=profilepic&userid=' + userId,
data: {up_picfile: profilePic},
transformRequest: formData,
headers: { 'Content-Type': undefined}
}).success(function (data, status, headers, config){
callback([data, status, headers, config]);
return;
}).error(function …
Run Code Online (Sandbox Code Playgroud) 我想知道是否有一种方法可以利用Dropbox API为应用程序全局授予访问权限.
这是我的情景.我正在开发一个Java应用程序,允许教师让他的学生提交作业.该应用程序将执行大量任务,但随后它会将文件上传到教师的Dropbox帐户.
我已经能够让应用程序进行身份验证并上传到每个特定用户的Dropbox/Apps/LabTab文件夹,但有一种方法可以使应用程序始终连接到教师的保管箱并上传到他的Dropbox/Apps/LabTab文件夹?
我想一个更简单的说明方式就是说我希望用户能够从我的单个应用程序授予对未经身份验证的请求的全局访问权限.
我想使用 Underscore.js 来确定数组中是否存在对象的实例。
一个示例用法是:
var enrollments = [
{ userid: 123, courseid: 456, enrollmentid: 1 },
{ userid: 123, courseid: 456, enrollmentid: 2 },
{ userid: 921, courseid: 621, enrollmentid: 3 }
]
Run Code Online (Sandbox Code Playgroud)
我希望能够识别用户 ID 和课程 ID 相同的唯一注册。
所以基本上,给定一个注册列表,我可以根据用户 ID 和课程 ID 的匹配来删除重复项,但不能根据注册 ID 来删除重复项。
我遇到一种情况,我需要在泛型声明中动态确定对象的类型(编译时间很好)。
我有一个这样的方法:
private async Task<T> Post<T>(string path, Request data)
{
var authPath = GetAuthenticatedPath(path);
var response = await _client.PostAsJsonAsync<Request>(authPath, data);
return response;
}
Run Code Online (Sandbox Code Playgroud)
问题是我真的需要它更像这样操作:
private async Task<T> Post<T>(string path, Request data)
{
var authPath = GetAuthenticatedPath(path);
var response = await _client.PostAsJsonAsync<data.GetType()>(authPath, data);
return response;
}
Run Code Online (Sandbox Code Playgroud)
因为我需要它在转换为 JSON 时将数据变量格式化为 ActualRequestType 而不是 Request 类型。问题是您无法在类型声明中执行 data.GetType() 。
c# ×2
javascript ×2
angularjs ×1
automation ×1
dropbox ×1
dropbox-api ×1
generics ×1
gruntjs ×1
java ×1
json ×1
json.net ×1
mongodb ×1
parsing ×1
shell ×1