首页 \ 问答 \ 杰克逊从Unix格式反序化Joda DateTime(Jackson deserialize Joda DateTime from Unix format)

杰克逊从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
更新时间:2023-04-23 16:04

最满意答案

-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 is CURLOPT_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 ...
  • 您应该在没有冒号的情况下使用它,它们用于指示您应该替换的东西。 但是,在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'); ...
  • 不是。多接口并行执行多个请求,但它使用非阻塞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 ...

相关文章

更多

最新问答

更多
  • 获取MVC 4使用的DisplayMode后缀(Get the DisplayMode Suffix being used by MVC 4)
  • 如何通过引用返回对象?(How is returning an object by reference possible?)
  • 矩阵如何存储在内存中?(How are matrices stored in memory?)
  • 每个请求的Java新会话?(Java New Session For Each Request?)
  • css:浮动div中重叠的标题h1(css: overlapping headlines h1 in floated divs)
  • 无论图像如何,Caffe预测同一类(Caffe predicts same class regardless of image)
  • xcode语法颜色编码解释?(xcode syntax color coding explained?)
  • 在Access 2010 Runtime中使用Office 2000校对工具(Use Office 2000 proofing tools in Access 2010 Runtime)
  • 从单独的Web主机将图像传输到服务器上(Getting images onto server from separate web host)
  • 从旧版本复制文件并保留它们(旧/新版本)(Copy a file from old revision and keep both of them (old / new revision))
  • 西安哪有PLC可控制编程的培训
  • 在Entity Framework中选择基类(Select base class in Entity Framework)
  • 在Android中出现错误“数据集和渲染器应该不为null,并且应该具有相同数量的系列”(Error “Dataset and renderer should be not null and should have the same number of series” in Android)
  • 电脑二级VF有什么用
  • Datamapper Ruby如何添加Hook方法(Datamapper Ruby How to add Hook Method)
  • 金华英语角.
  • 手机软件如何制作
  • 用于Android webview中图像保存的上下文菜单(Context Menu for Image Saving in an Android webview)
  • 注意:未定义的偏移量:PHP(Notice: Undefined offset: PHP)
  • 如何读R中的大数据集[复制](How to read large dataset in R [duplicate])
  • Unity 5 Heighmap与地形宽度/地形长度的分辨率关系?(Unity 5 Heighmap Resolution relationship to terrain width / terrain length?)
  • 如何通知PipedOutputStream线程写入最后一个字节的PipedInputStream线程?(How to notify PipedInputStream thread that PipedOutputStream thread has written last byte?)
  • python的访问器方法有哪些
  • DeviceNetworkInformation:哪个是哪个?(DeviceNetworkInformation: Which is which?)
  • 在Ruby中对组合进行排序(Sorting a combination in Ruby)
  • 网站开发的流程?
  • 使用Zend Framework 2中的JOIN sql检索数据(Retrieve data using JOIN sql in Zend Framework 2)
  • 条带格式类型格式模式编号无法正常工作(Stripes format type format pattern number not working properly)
  • 透明度错误IE11(Transparency bug IE11)
  • linux的基本操作命令。。。