我正在测试我的Web API.模拟我有这个数据:
var objs = ((JArray)JsonConvert.DeserializeObject("{ \"PrintId\":10,\"Header\":\"header\",\"TC\":\"tc\",\"CompanyRef\":\"00000000-0000-0000-0000-000000000000\"}")).Values<JObject>();
Run Code Online (Sandbox Code Playgroud)
这给了我错误:
无法将"Newtonsoft.Json.Linq.JObject"类型的对象强制转换为"Newtonsoft.Json.Linq.JArray"
事情是工作.我必须改变一些东西,但我不知道是什么.
我的目的是将此JSON对象转换为名为.NET对象的列表,Print其中包含以下字段:
PrintId
Header
TX
CompnayRef
Run Code Online (Sandbox Code Playgroud) 我有一个非常大的CSV文件,包含100列.为了说明我的问题,我将使用一个非常基本的例子.
我们假设我们有一个CSV文件.
Run Code Online (Sandbox Code Playgroud)in value d f 0 975 f01 5 1 976 F 4 2 977 d4 1 3 978 B6 0 4 979 2C 0
我想选择一个特定的列.
import pandas
data = pandas.read_csv("ThisFile.csv")
Run Code Online (Sandbox Code Playgroud)
为了选择我使用的前两列
data.ix[:,:2]
Run Code Online (Sandbox Code Playgroud)
为了选择不同的列,如第2和第4列.我该怎么办?
还有另一种方法可以通过重写CSV文件来解决此问题.但它是巨大的文件; 所以我就是这样避免的.
我遇到过这段代码:
return someFunctionThatReturnsAnArray()
.map((action) => void dispatch(action))
.run();
Run Code Online (Sandbox Code Playgroud)
谁能建议为什么要void在映射函数中添加前缀以便它undefined每次都返回?
背景:
我已经能够XMPP在android中使用asmack库实现一对一聊天.我也可以向服务器发送状态.我在OpenFire基于聊天的应用程序中使用服务器.
问题:
我正在使用connection.addPacketListener(new PacketListener() 接收消息和IQ数据包,对于我已经将它分类的消息包
PacketFilter Chatfilter = new MessageTypeFilter(Message.Type.chat);
connection.addPacketListener(new PacketListener() {
public void processPacket(Packet packet) {
Message message = (Message) packet;
if (message.getBody() != null) {
String fromName = StringUtils.parseBareAddress(message.getFrom());
Log.i("XMPPClient", "Got text [" + message.getBody() + "] from [" + fromName + "]");
messages.add(fromName + ":");
m1=message.getBody();
messages.add(message.getBody());
// Add the incoming message to the list view
/* mHandler.post(new Runnable() {
public void run() {
setListAdapter();
recieve.setText(m1);
}
});*/ …Run Code Online (Sandbox Code Playgroud) 如果我遗漏了任何东西,请告诉我.我无法弄清楚为什么我的views/references /文件夹无法访问.既不可用new.html.erb也不index.html.erb可用.当我转到localhost:3000/references我的错误是:
RuntimeError in ReferencesController#index
Circular dependency detected while autoloading constant ReferencesController
Run Code Online (Sandbox Code Playgroud)
我相信这是设置,它不应该是一个Rails问题,因为我的其他控制器工作正常.
我的路线文件中有resources :references我的rake路线产生:
references GET /references(.:format) references#index
POST /references(.:format) references#create
new_reference GET /references/new(.:format) references#new
edit_reference GET /references/:id/edit(.:format) references#edit
reference GET /references/:id(.:format) references#show
PATCH /references/:id(.:format) references#update
PUT /references/:id(.:format) references#update
DELETE /references/:id(.:format) references#destroy
Run Code Online (Sandbox Code Playgroud)
所以我试着通过这个到达我的索引页面,这应该是正确的路径.
<%= link_to 'References', references_path, class: 'navbar-brand' %>
Run Code Online (Sandbox Code Playgroud)
我的模特:
class Reference < ActiveRecord::Base
belongs_to :user
end
Run Code Online (Sandbox Code Playgroud)
我的控制器:
class ReferencesControllers < ApplicationController
def index
@references = Reference.all
end
Run Code Online (Sandbox Code Playgroud)
谷歌搜索后,似乎每个类似的问题都是从Rails 3升级到Rails …
ruby ruby-on-rails circular-dependency controllers ruby-on-rails-4
我正在尝试使用以下方法使用jQuery Ajax将数据发布到MVC操作.但是在控制器内部,所有模型属性都是null.不知道我在这里缺少什么.
.CSHTML
<form id="MyForm">
<input name="PersonName" type="text" />
<input name="Address" type="text" />
<select name="States" multiple="multiple">
<option value="TX">Texas</option>
<option value="OK">Oklahoma</option>
<option value="OH">Ohio</option>
</select>
<select name="Status">
<option value="1">Active</option>
<option value="2">Deleted</option>
<option value="3">Pending</option>
</select>
<input type="button" value="Save" id="Save" />
Run Code Online (Sandbox Code Playgroud)
JavaScript的
$(function () {
$("#Save").click(function (e) {
var dataToPost = $("#MyForm").serialize()
$.ajax(
{
type: "POST",
data: JSON.stringify(dataToPost),
url: "Working/Save",
contentType: 'application/json; charset=utf-8'
})
})
})
Run Code Online (Sandbox Code Playgroud)
调节器
public class WorkingController : Controller
{
// GET: Working
public ActionResult Index()
{
return View(); …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用Microsoft.JQuery.Unobtrusive.Ajax。我首先使用NuGet安装软件包,然后按预期可以在依赖项中看到它。
我的问题是我找不到引用脚本的方法,因此无法在视图中使用它。在这里,我看到应该将其添加到布局中:
<script src="~/lib/Microsoft.jQuery.Unobtrusive.Ajax/jquery.unobtrusive-ajax.min.js"></script>
Run Code Online (Sandbox Code Playgroud)
但是该路径导致没有文件:
这是我的控制器动作:
[HttpPost]
public IActionResult OrderItem([Bind("Id,Quantity")] Item item)
{
return Json(new { foo= item.Id, boo= item.Quantity});
}
Run Code Online (Sandbox Code Playgroud)
表格:
<form asp-action="OrderItem" asp-controller="Menu" method="POST" data-ajax="true" data-ajax-update="#divEmp" data-ajax-mode="replace" data-ajax-complete="onComplete" data-ajax-failure="onFailed" data-ajax-success="onSuccess">
<input asp-for="@i.Id" value="@i.Id" type="hidden" name="Id" />
<input asp-for="@i.Quantity" value="@i.Quantity" type="number" name="Quantity" class="form-group" />
<button class="btn btn-primary" type="submit">Add to Order</button>
</form>
Run Code Online (Sandbox Code Playgroud)
我从控制器返回了JSON,但是我被重定向到了显示JSON数据的页面。我的目标是使用JSON对象中的数据来更新同一视图中的组件。
.net c# unobtrusive-ajax visual-studio-2017 asp.net-core-mvc-2.0
在Meteor.js中,如果我将代码放在客户端和服务器中:
var col = new Collection(null);
Run Code Online (Sandbox Code Playgroud)
有什么区别:
var col = new Collection('someName',{connection:null});
Run Code Online (Sandbox Code Playgroud)
从文档:
新的Meteor.Collection(名称,[选项])
name String:集合的名称.如果为null,则创建非托管(非同步)本地集合.
connection Object将管理此集合的服务器连接.如果未指定,则使用默认连接.传递调用DDP的返回值.连接以指定其他服务器.传递null以指定无连接.
从它的内容来看,似乎上面的代码是相同的:在客户端和服务器上都有两个非连接的集合.但为什么它需要有两种不同的方式来产生相同的结果.我的观点是名称没关系,因为它们没有连接(没有必要发送DDP消息,需要指定集合名称.)我错过了什么?谢谢.
我已多次检查/比较SQL语句,但它仍然无效.我正在使用WorkBench 6.3和MySQL.它给了我一个错误:
1064语法错误:'IF'在此位置不是有效输入.
IF(EXISTS(SELECT * FROM RECORDS WHERE FORMID = 200002016 AND TimeUploaded > '2016-07-17 03:13:39' AND TimeUploaded < '2016-07-17 03:13:39'))
Begin
SELECT TimeUploaded from RECORDS
End;
Run Code Online (Sandbox Code Playgroud) 以下请求经常超时:
<body rid='57993057' xmlns='http://jabber.org/protocol/httpbind' sid='1db840cbfd20e3922f594cc2017421a1858cca7a'><a xmlns='urn:xmpp:sm:3' h='9'/></body>
Run Code Online (Sandbox Code Playgroud)
控制台日志显示:
请求的资源上不存在"Access-Control-Allow-Origin"标头.
我正在使用带有haproxy的ejabberd服务器.