我试图从URL解析JSON,然后将数据添加到数组.我正在使用GSON库.
我的JSON具有以下格式:
[
{
"img-src":"http://website.com/images/img1.png",
"URL":"http://google.com"
},
{
"img-src":"http://website.com/images/img2.jpg",
"URL":"http://yahoo.com"
}
]
Run Code Online (Sandbox Code Playgroud)
我想在一个单独的线程中获取上述数据,我有以下代码:
public class Async extends AsyncTask<String, Integer, Object>{
@Override
protected String doInBackground(String... params) {
return null;
}
}
Run Code Online (Sandbox Code Playgroud)
如何获取每个"img-src"和"URL"值?
我在mvc4通过'Process'类调用.exe文件时有一个API .
此.exe使用log4net,并运行另一个.exe,将文件导出到目录和子目录.在进程结束时,.exe发布到http API.
Process p = new Process();
p.StartInfo.FileName = ConfigurationManager.AppSettings["ExtractToolPath"];
p.StartInfo.Arguments = this.strcommand;
p.StartInfo.RedirectStandardOutput = true;
p.StartInfo.UseShellExecute = false;
p.StartInfo.Verb = "runas";
p.StartInfo.RedirectStandardInput = true;
p.Start();
string s = p.StandardOutput.ReadToEnd();
p.WaitForExit();
Run Code Online (Sandbox Code Playgroud)
字符串's'返回""(空白字符串).
该s放慢参数得到什么打印到控制台窗口.我在.exe的开头做了一个打印,因此我知道它甚至没有启动过程.
重要提示:当我删除log4net记录器时,'s'参数会获得一些输出,但是在执行任何需要写入权限的命令时它会失败.
我试图授予IIS可执行权限,并使用管理员用户名和密码进行模拟.我把目录分享给大家.什么都没有帮助.
我有以下继承自DataTable的类:
public class ExcelStaticDataTable : DataTable
{
public List<ExcelStaticDataTable> SubTables { get; set; }
public ExcelStaticDataTable(string tableName): base(tableName)
{
SubTables = new List<ExcelStaticDataTable>();
}
}
Run Code Online (Sandbox Code Playgroud)
你知道为什么我在MissingMethodException执行以下操作时获得"为此对象定义的无参数构造函数":
ExcelStaticDataTable table=new ExcelStaticDataTable("table1");
table.Clone();
Run Code Online (Sandbox Code Playgroud)
这两段代码都在不同的dll中,只是为了澄清.这里的堆栈跟踪:
at System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean noCheck, Boolean& canBeCached, RuntimeMethodHandleInternal& ctor, Boolean& bNeedSecurityCheck)
at System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache, StackCrawlMark& stackMark)
at System.RuntimeType.CreateInstanceDefaultCtor(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache, StackCrawlMark& stackMark)
at System.Activator.CreateInstance(Type type, Boolean nonPublic)
at System.Data.DataTable.CreateInstance()
at System.Data.DataTable.Clone(DataSet cloneDS)
at System.Data.DataTable.Clone()
at System.Data.DataTable.Copy()
at ..........cs:line …Run Code Online (Sandbox Code Playgroud) 通过Android,您可以访问assets文件夹(例如,我有我的字体)getAssets().但是,我没有看到任何方式来反省那里的内容,并获得动态的资产列表.
这不可能吗?如果没有,是否有一个替代位置来保存字体等内容,以便我可以在运行时提取动态列表中的内容?
所以我有一个C#winform,其中包含一个面板和一个属于该面板的文本框。
问题是文本框在我的winform上显示为一个洞。我可以看到其背后的内容(我的桌面,其他窗口等)。对我来说,这听起来像是个错误,因为经过Google的一些研究,我得出的结论是文本框不能透明。
如果以下任何情况相关:winform透明键设置为透明,文本框backcolor=white和forecolor=black。
我试图重新启动Visual Studio和计算机,但问题仍然存在。
有什么办法可以解决?
MongooseJS在查看for的文档时MongoDB/Node.js,似乎可以在对象上指定索引,如下所示:
var MyModelSchema = new Schema({ name: String, index: true });
var MyModel = mongoose.model('MyModel', MyModelSchema);
MyModel.on('index', function()
{
doStuff();
});
Run Code Online (Sandbox Code Playgroud)
根据文档,Mongoose 将ensureIndex()在启动时调用,除非该"autoIndex"选项在模式上显式设置为 false。一旦完成,'index'事件将在模型上发出,这将触发回调。
我的理解是,这允许模型的用户确保在使用模型之前所有索引都已完成。
我相信我听说过通过 这样做app.configure,尽管我不确定如何做到这一点。也许还有另一种方法可以保证在依赖导出模型的应用程序的其他部分之前完成此索引操作?
这个应该如何正确使用呢?
我正在处理一些奇怪的遗留代码。他们有一个实现 JPanel 的自定义对象。此JPanel对象是主应用程序中的辅助弹出屏幕。我遇到的问题是检测辅助弹出屏幕何时关闭。
我尝试WindowListener为该类实现 a ,但是当我尝试添加它时,没有JFrame与此对象关联。我假设这是因为他们使用的是自定义对象,并且它是一个嵌入式弹出屏幕。
我试图检索一个JFrame使用:
JFrame parentFrame = (JFrame) SwingUtilities.getWindowAncestor(this);
Run Code Online (Sandbox Code Playgroud)
在NullPointerException. 我不知道为什么在此页面上很难检测到右上角的“x”关闭按钮!我应该提到他们能够将鼠标和键侦听器添加到嵌入在JPanel. 但是整个窗口的外部侦听器给我带来了麻烦。
(请耐心等待,这是我的第一个 stackoverflow 帖子,我是 Swing 的新手。)
非常感谢!!
鉴于以下映射,我需要获得符合以下条件的结果
电子邮件和旅行证件可以指一系列物品.
{
"profile":{
"properties":{
"date_of_birth":{
"type":"date",
"store":"no"
},
"first_name":{
"type":"string",
"store":"no"
},
"last_name":{
"type":"string",
"store":"no"
},
"email":{
"type":"string",
"store":"no"
},
"active":{
"type":"string",
"store":"no"
},
"travel_document":{
"properties" : {
"countryOfCitizenship" : {"type" : "string"},
"countryOfIssue" : {"type" : "string"},
"expirationDate" : {"type" : "date"},
"nationality" : {"type" : "string"},
"number" : {"type" : "string"},
"addressLines" : {"type": "string"},
"issuedForAreaCode" : {"type": "string"},
"type" : {"type": "string"}
}
} …Run Code Online (Sandbox Code Playgroud) 我一直在网上寻找一种在Objective C中播放声音的方法,我找到了很多答案.但是,当我尝试播放三个"Apple Mach-O Linker Errors"时会弹出.
这是我的代码:
viewController.m
-(IBAction)shoot{
tempSound *sound = [[tempSound alloc]init];
[sound playSound:@"test" :@"wav"]
}
Run Code Online (Sandbox Code Playgroud)
tempSound.h
#import <UIKit/UIKit.h>
#import <Foundation/Foundation.h>
#import <AudioToolbox/AudioToolbox.h>
#import <AVFoundation/AVFoundation.h>
@interface tempSound : NSObject{
SystemSoundID audioEffect;
}
-(void)playSound: (NSString*) fName : (NSString*) ext;
@end
Run Code Online (Sandbox Code Playgroud)
tempSound.m
@implementation tempSound
-(void)playSound:(NSString *)fName :(NSString *)ext
{
NSString *path = [[NSBundle mainBundle] pathForResource : fName ofType :ext];
if ([[NSFileManager defaultManager] fileExistsAtPath:path]) {
NSURL *pathURL = [NSURL fileURLWithPath:path];
AudioServicesCreateSystemSoundID((__bridge CFURLRef)pathURL, &audioEffect);
AudioServicesPlaySystemSound(audioEffect);
}
else{
NSLog(@"Error, file not found: %@",path);
} …Run Code Online (Sandbox Code Playgroud) 我确定已经问过这个问题,但我不知道该搜索什么.
我有一些Message对象,包含以下字段{selected[BOOL], messageText[STR]}.我想过滤此数组以仅获取对象selected=TRUE.到现在为止还挺好.
NSArray *messagesFiltered = [self.fetchedResultsController.fetchedObjects filteredArrayUsingPredicate:[NSPredicate predicateWithFormat:@"selected == TRUE"]];
Run Code Online (Sandbox Code Playgroud)
但是,我不需要返回数组中的对象本身,我需要一个messageText字符串数组.如何修改predicate只返回messageText字符串而不是整个对象?