杰克逊从Unix格式反序化Joda DateTime(Jackson deserialize Joda DateTime from Unix format)
从JSON反序列化时,我的日期是用Unix纪元时间写的(/ Date(1379542610387 + 1000)/)。
我知道以这种方式序列化Json中的日期是非常标准的,但是如何将这个值反序列化为Joda DateTime?
当杰克逊看到这样的价值时,它会吐出:
Invalid format: "/Date(1379542610387+1000)/"
When deserializing from JSON I have dates that are written in Unix Epoch time (/Date(1379542610387+1000)/).
I understand that is it pretty standard to serialize dates in Json this way, however how can I get this value deserialized into a Joda DateTime?
When jackson see's a value like this it spits out:
Invalid format: "/Date(1379542610387+1000)/"
原文:https://stackoverflow.com/questions/18906036
最满意答案
与
-u
选项的php等价物是CURLOPT_USERPWD
。curl_setopt($ch, CURLOPT_USERPWD, 'user.ca:password');
最后你会得到这样的东西:
$ch = curl_init(); curl_setopt($ch, CURLOPT_URL, "https://api.github.com/repos/xyz/abc/releases"); curl_setopt($ch, CURLOPT_USERPWD, 'user.ca:password'); curl_setopt($ch, CURLOPT_USERAGENT,'Awesome-Octocat-App'); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); $fetch = curl_exec($ch); curl_close($ch);
The php equivalent of the
-u
option isCURLOPT_USERPWD
.curl_setopt($ch, CURLOPT_USERPWD, 'user.ca:password');
In the end you will have something like this:
$ch = curl_init(); curl_setopt($ch, CURLOPT_URL, "https://api.github.com/repos/xyz/abc/releases"); curl_setopt($ch, CURLOPT_USERPWD, 'user.ca:password'); curl_setopt($ch, CURLOPT_USERAGENT,'Awesome-Octocat-App'); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); $fetch = curl_exec($ch); curl_close($ch);
相关问答
更多-
在Ubuntu 16.04中,默认的PHP版本是7.0,如果你想使用不同的版本,那么你需要根据PHP版本安装PHP包: PHP 7.0: sudo apt-get install php-curl PHP 5.6: sudo apt-get install php5.6-curl PHP 5.5: sudo apt-get install php5.5-curl In Ubuntu 16.04 default PHP version is 7.0, if you want to use different ...
-
您的数组是您的函数的本地数组,因此会重置每个调用。 尝试添加全局声明,您将获得您期望的(所有值); function request_callback($response) { global $associative_array; $temporary_array = json_decode($response, true); $associative_array[] = array('name' => $temporary_array['name'],'id' => $tempor ...
-
获取github下载次数(Get number of github downloads)[2024-03-07]
您应该在没有冒号的情况下使用它,它们用于指示您应该替换的东西。 但是,在https://api.github.com/repos/benlindsay/polymer-reptation/releases列出所有版本返回一个空数组...没有发布我的猜测是API还没有赶上。 如果这不能立即解决,请联系GitHub。 You should use it without the colons, they are there to indicate stuff you should replace. However ... -
我不敢相信我这样做了。 为了记录,Nevik对组织的形式是正确的: https://api.github.com/repos/
/ 我这样设置我的网址: $url = 'https://api.github.com/repos/$org_name/$repo_name'; 看到问题了吗? 在PHP中,单引号不解析内部变量,双引号确实如下: $url = "https://api.github.com/repos/$org_name/$repo_name"; 一 ... -
检查您是否未在浏览器中登录。 如果是这样,你可能得到不同的结果 Check that you are not logged in in the browser. You may get different results if so.
-
您在请求中发送JSON有效负载,但您链接的文档表示您需要使用原始二进制文件内容作为有效负载发出POST请求。 您也错过了正确设置Content-Type标头。 更改curl调用以将文件作为有效负载提供,将文件名作为参数添加到URL并设置标题,如文档中所述,它应该可以正常工作。 生成的命令应该是这样的: curl 'https://api.github.com/repos/owner/my_repo/releases/:id/assets?access_token=acces_token&name=foo.z ...
-
与-u选项的php等价物是CURLOPT_USERPWD 。 curl_setopt($ch, CURLOPT_USERPWD, 'user.ca:password'); 最后你会得到这样的东西: $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, "https://api.github.com/repos/xyz/abc/releases"); curl_setopt($ch, CURLOPT_USERPWD, 'user.ca:password'); ...
-
PHP-CURL的curl_multi_exec在内部是否真的是多线程的?(Is PHP-CURL's curl_multi_exec really multithreaded internally?)[2022-07-17]
不是。多接口并行执行多个请求,但它使用非阻塞API调用。 当特定传输需要解析主机名时,人们可能面临的问题就会发生,因为大多数操作系统中的标准主机名解析器功能是同步的,这使得每个解决方案阻止所有其他传输。 这在libcurl中通过提供替代解析器后端来解决,例如为解析使用c-ares而构建的后端解析器,以及另一个在单独线程中触发“库存解析器”的解析器 - 所谓的线程解析器。 No. The libcurl multi interface (that PHP uses under the hood to do t ... -
CURLOPT_VERBOSE设置不需要调试版本的cURL,但默认情况下CURLOPT_VERBOSE信息输出到STDERR ,只能在控制台上看到。 因此,如果您从浏览器运行PHP,则不会在您可以看到的任何位置发送详细输出。 您可以将选项CURLOPT_STDERR为文件句柄,并在那里写入详细输出。 你应该能够做到这一点: $stdout = fopen('php://output', 'w+'); $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, 'ht ...
-
GitHub将其专有的Releases功能与常规Git标签混合在一起。 您在ffmpeg中看到的许多“版本”实际上只是标签。 这是一个真实版本的示例 。 请注意它如何包含比标记更多的信息。 尽管他们的Web UI显示标签与版本混合,但GitHub的发布API端点不包含常规标签 : 这将返回一个版本列表,其中不包含尚未与版本关联的常规Git标记。 要获取Git标记列表,请使用Repository Tags API 。 使用标签端点作为GitHub建议提供更多结果,并包含您期望的Link头: curl -is ...