我有一个字符串,我想从中获取一些值.
我的字符串看起来像:
STRING1:
"{\r\n \"id\": \"100000280905615\",
\r\n \"name\": \"Jerard Jones\",
\r\n \"first_name\": \"Jerard\",
\r\n \"last_name\": \"Jones\",
\r\n \"link\": \"https://www.facebook.com/Jerard.Jones\",
\r\n \"username\": \"Jerard.Jones\",
\r\n \"gender\": \"female\",
\r\n \"locale\": \"en_US\"\r\n}"
Run Code Online (Sandbox Code Playgroud)
字符串2:
"{\r\n \"id\": \"100000390001929\",
\r\n \"name\": \"\\u05d1\\u05d2\\u05e8\\u15dc\\u25d9 \\u05d1\\u05e8\\u05d5\\u05e9\",
\r\n \"first_name\": \"\\u05d4\\u05d2\\u05e7\\u02dc\\u05d9\",
\r\n \"last_name\": \"\\u05d1\\u05e8\\u05d5\\u05e9\",
\r\n \"link\": "https://www.facebook.com/people/\\u05d2\\u05d1\\u05e@\\u05dc\\u05d9-\\u05d1\\u05e8\\u05d4\\u05e9/100000390001929\",
\r\n \"gender\": \"female\",
\r\n \"locale\": \"he_IL\"\r\n}"
Run Code Online (Sandbox Code Playgroud)
不幸的是,有一种情况是字符串将采用相同的概念,但没有一些参数:
STRING3:
"{\r\n \"id\": \"100000390001929\",
\r\n \"last_name\": \"\\u05d1\\u05e8\\u05d5\\u05e9\",
\r\n \"gender\": \"female\",
\r\n \"locale\": \"he_IL\"\r\n}"
Run Code Online (Sandbox Code Playgroud)
我怎样才能得到的值:id
,first_name
,last_name
,gender
,locale
?
任何帮助赞赏!
我有一个字符串:"www.google.com.sdg.jfh.sd"
我想找到在"sdg"之后找到的第一个".s"字符串.
所以我的索引为"sdg",由:
var start_index = str.indexOf("sdg");
Run Code Online (Sandbox Code Playgroud)
现在我需要找到在"sdg"之后找到的第一个".s"索引
任何帮助赞赏!
我有一些文件要上传,一些文件失败,因为帖子是异步的而不是同步的..
我正在尝试将此调用作为同步调用..
我想等待回应.
如何将此调用设为同步?
static async Task<JObect> Upload(string key, string url, string
sourceFile, string targetFormat)
{
using (HttpClientHandler handler = new HttpClientHandler {
Credentials = new NetworkCredential(key, "")
})
using (HttpClient client = new HttpClient(handler))
{
var request = new MultipartFormDataContent();
request.Add(new StringContent(targetFormat), "target_format");
request.Add(new StreamContent(File.OpenRead(sourceFile)),
"source_file",
new FileInfo(sourceFile).Name);
using (HttpResponseMessage response = await client.PostAsync(url,
request).ConfigureAwait(false))
using (HttpContent content = response.Content)
{
string data = await content.ReadAsStringAsync().ConfigureAwait(false);
return JsonObject.Parse(data);
}
}
}
Run Code Online (Sandbox Code Playgroud)
任何帮助赞赏!
我想将div粘贴到其父元素的顶部.
它通常有效,除了在这个例子中:http://jsfiddle.net/HV9HM/2859/
function sticky_relocate() {
var window_top = $('#container').scrollTop();
var div_top = $('#sticky-anchor').offset().top;
if (window_top > div_top) {
$('#sticky').addClass('stick');
$('.stick').css('width', $('#sticky').next().css('width'));
} else {
$('#sticky').removeClass('stick');
}
}
$(function () {
$('#container').scroll(sticky_relocate);
sticky_relocate();
});
Run Code Online (Sandbox Code Playgroud)
.child {
height: 200px;
background: gray;
}
#sticky {
padding: 0.5ex;
width: 600px;
background-color: #333;
color: #fff;
font-size: 2em;
border-radius: 0.5ex;
}
#sticky.stick {
position: fixed;
z-index: 10000;
border-radius: 0 0 0.5em 0.5em;
}
body {
margin: 1em;
}
p {
margin: 1em auto; …
Run Code Online (Sandbox Code Playgroud)当用户按下ctrl + s
按键但Chrome崩溃时,我正在尝试将我的HTML文件保存在Chrome中.
(我只想下载我的HTML文件的源代码)
我读到它发生是因为我的文件大于1.99M ..
在第一次尝试中(在我知道Chrome崩溃之前):
function download(filename, text) {
var pom = document.createElement('a');
pom.setAttribute('href', 'data:text/plain;charset=utf-8,' + encodeURIComponent(text));
pom.setAttribute('download', filename);
pom.click();
}
download('test.html', "<html>" + document.getElementsByTagName('html')[0].innerHTML + "</html>");
Run Code Online (Sandbox Code Playgroud)
在我读到关于崩溃的第二次尝试之后,我使用了blob
:
function dataURItoBlob(dataURI) {
var byteString = atob(dataURI.split(',')[1]);
var mimeString = dataURI.split(',')[0].split(':')[1].split(';')[0]
var ab = new ArrayBuffer(byteString.length);
var ia = new Uint8Array(ab);
for (var i = 0; i < byteString.length; i++) {
ia[i] = byteString.charCodeAt(i);
}
var bb = new BlobBuilder();
bb.append(ab);
return bb.getBlob(mimeString);
}
function download(dataURI) …
Run Code Online (Sandbox Code Playgroud) 我想构建一个自动化测试,所以我必须知道chrome控制台中出现的错误.
有一个选项来获取控制台中出现的错误行?
要查看控制台:右键单击页面中的某个位置,单击"检查元素",然后转到"控制台".
我有一个想要他的名字的人物Step 2 of 3: Simulation Plot Window
,但它的名字是:figure 2: Step 2 of 3: Simulation Plot Window
.
如何将他的名字改为我想要的名字?
我不知道是否有必要,但在我写的代码的开头:
hFig = figure('Name','window 1','Visible','Off');
Run Code Online (Sandbox Code Playgroud)
为了我的代码结束,我写道:
hFig = figure('Name','Step 2 of 3: Simulation Plot Window','Menubar','none', 'Resize','off', ...
'WindowStyle','modal', 'Position',[300 300 1150 600]);
Run Code Online (Sandbox Code Playgroud) 问题:
我使用了Ofir Dagan的github项目:存储跨域本地存储.
它实现了html5本地存储:https: //github.com/ofirdagan/cross-domain-local-storage
问题:
Safari默认情况下不允许第三方cookie(其他浏览器允许).
Safari隐私首选项包括:
默认值为:"允许我访问的网站".
我读到了这些设置:
始终阻止 - 阻止所有第一方Cookie并阻止所有第三方Cookie.
仅允许来自当前网站 - 允许所有第一方Cookie并阻止所有第三方Cookie.
允许来自我访问的网站 - 允许所有第一方Cookie并阻止所有第三方Cookie,除非该第三方同时是第一方(基于当前Cookie和浏览历史记录).
始终允许 - 允许所有第一方Cookie并允许所有第三方Cookie.
解决方案我试过:
使用iframe(像素)的本地存储 - 我认为它不再适用于Safari - 是否有任何解决方法可以在iframe中为Safari设置第三方cookie?
我认为有一种方法可以在Safari上的第一方和第三方站点之间共享本地存储.(Facebook.com和Booking.com共享不同域之间的数据).
我成功地通过删除API并自己编写来实现它,但我不想删除API并自己实现它(希望有一个小的修复以支持Safari):
Iframe.html
:
window.addEventListener('cors_event', function(event) {
if(event.event_id === 'my_cors_message'){
if (event.data.options.funcName == "SetItem") {
localStorage.setItem(event.data.options.key, event.data.options.value);
}
else if (event.data.options.funcName == "GetItem") {
return localStorage.getItem(event.data.options.key);
}
}
});
Run Code Online (Sandbox Code Playgroud)
MainPage:
<iframe id="target" src="iframe.html" frameborder="1"></iframe>
<script>
var target = document .getElementById('target');
target.onload = function(){
target.contentWindow.postMessage('set', '*')
}
</script> …
Run Code Online (Sandbox Code Playgroud) 我在C++中定义了一个链表.我试图设置一个NULL值到变量头(在构造函数中Movie_LinkedList
),但我得到:
movie.h(40):错误C2065:'NULL':未声明的标识符
请注意,我不能包括任何图书馆除外iostream
任何帮助赞赏!
我有2个文件:
Point.h
:
class Point {
int x;
int y;
char* name;
public:
Point() { name = new char[5]; }
~Point() { delete[] name; }
};
Run Code Online (Sandbox Code Playgroud)
并且Line.h
:
class Point;
class Line {
Point* p;
public:
Line() {
p = new Point[2];
....
...
}
~Line() {
delete[] p;
}
};
Run Code Online (Sandbox Code Playgroud)
但是当我编译时,我得到了下一个错误:
deletion of pointer to incomplete type 'Point'; no destructor called
Run Code Online (Sandbox Code Playgroud)
任何帮助赞赏!
javascript ×5
c# ×3
c++ ×2
html ×2
jquery ×2
pointers ×2
asp.net-mvc ×1
class ×1
cross-domain ×1
css ×1
destructor ×1
html5 ×1
httpresponse ×1
json ×1
matlab ×1
null ×1
safari ×1
selenium ×1