-
Notifications
You must be signed in to change notification settings - Fork 6.5k
反序列化带时区的时间字符串失败 #2754
Comments
hi 有人能帮忙看下这个问题吗? |
It’s 99 Southbound in Lodi on frontage road. You can see him from the
freeway yesterday
…On Wed, 18 Sep 1 Reiwa at 4:32 AM, DavidWei ***@***.***> wrote:
你好,我在Java中使用1.2.60的fastjson反序列化如下json时会出现反序列化失败:
待反序列化的Json内容:
"{"p1":"2019-09-18T20:35:00+12:45"}"
用于反序列化的类:
public class C{
public Calendar p1;
}
我看了下fastjson的底层源码,发现是JSONScanner类的第479行代码(scanISO8601DateIfMatch方法中)有个判断if
(t3 != '0' && t3 != '3'){return
false;}导致的,当时间带时区且时区不是0分或者30分时,就认为不是ISO8601的格式,但实际上的确有些地方的时区是45分,比如新西兰的时区是+12:45,具体可以见下面的wiki:
https://en.wikipedia.org/wiki/List_of_UTC_time_offsets
同时,我看了下ISO8601的wiki,规范中并未限制时区的分钟部分只能是0或者30分,见下wiki:
https://en.wikipedia.org/wiki/ISO_8601#Time_offsets_from_UTC
所以麻烦看一看这个问题是否是bug或者是有什么其他方法可以绕过这个问题吧?
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#2754?email_source=notifications&email_token=AMX2YHMV3K55QHLELBWXM6TQKIGUXA5CNFSM4IX5M3U2YY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4HMDVBWQ>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AMX2YHOM4KI7CM3MWSWVPFDQKIGUXANCNFSM4IX5M3UQ>
.
|
Probably crawled into the nearby field.
On Mon, 23 Sep 1 Reiwa at 8:06 PM, Vixenx Aristotle <
xvilta.amarantesx@gmail.com> wrote:
… It’s 99 Southbound in Lodi on frontage road. You can see him from the
freeway yesterday
On Wed, 18 Sep 1 Reiwa at 4:32 AM, DavidWei ***@***.***>
wrote:
> 你好,我在Java中使用1.2.60的fastjson反序列化如下json时会出现反序列化失败:
> 待反序列化的Json内容:
> "{"p1":"2019-09-18T20:35:00+12:45"}"
>
> 用于反序列化的类:
> public class C{
> public Calendar p1;
> }
>
> 我看了下fastjson的底层源码,发现是JSONScanner类的第479行代码(scanISO8601DateIfMatch方法中)有个判断if
> (t3 != '0' && t3 != '3'){return
> false;}导致的,当时间带时区且时区不是0分或者30分时,就认为不是ISO8601的格式,但实际上的确有些地方的时区是45分,比如新西兰的时区是+12:45,具体可以见下面的wiki:
> https://en.wikipedia.org/wiki/List_of_UTC_time_offsets
> 同时,我看了下ISO8601的wiki,规范中并未限制时区的分钟部分只能是0或者30分,见下wiki:
> https://en.wikipedia.org/wiki/ISO_8601#Time_offsets_from_UTC
>
> 所以麻烦看一看这个问题是否是bug或者是有什么其他方法可以绕过这个问题吧?
>
> —
> You are receiving this because you are subscribed to this thread.
> Reply to this email directly, view it on GitHub
> <#2754?email_source=notifications&email_token=AMX2YHMV3K55QHLELBWXM6TQKIGUXA5CNFSM4IX5M3U2YY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4HMDVBWQ>,
> or mute the thread
> <https://github.com/notifications/unsubscribe-auth/AMX2YHOM4KI7CM3MWSWVPFDQKIGUXANCNFSM4IX5M3UQ>
> .
>
|
You can probably see him from theFrom 99 S. downloadSouth bound
On Mon, 23 Sep 1 Reiwa at 8:06 PM, Vixenx Aristotle <
xvilta.amarantesx@gmail.com> wrote:
… Probably crawled into the nearby field.
On Mon, 23 Sep 1 Reiwa at 8:06 PM, Vixenx Aristotle <
***@***.***> wrote:
> It’s 99 Southbound in Lodi on frontage road. You can see him from the
> freeway yesterday
>
> On Wed, 18 Sep 1 Reiwa at 4:32 AM, DavidWei ***@***.***>
> wrote:
>
>> 你好,我在Java中使用1.2.60的fastjson反序列化如下json时会出现反序列化失败:
>> 待反序列化的Json内容:
>> "{"p1":"2019-09-18T20:35:00+12:45"}"
>>
>> 用于反序列化的类:
>> public class C{
>> public Calendar p1;
>> }
>>
>> 我看了下fastjson的底层源码,发现是JSONScanner类的第479行代码(scanISO8601DateIfMatch方法中)有个判断if
>> (t3 != '0' && t3 != '3'){return
>> false;}导致的,当时间带时区且时区不是0分或者30分时,就认为不是ISO8601的格式,但实际上的确有些地方的时区是45分,比如新西兰的时区是+12:45,具体可以见下面的wiki:
>> https://en.wikipedia.org/wiki/List_of_UTC_time_offsets
>> 同时,我看了下ISO8601的wiki,规范中并未限制时区的分钟部分只能是0或者30分,见下wiki:
>> https://en.wikipedia.org/wiki/ISO_8601#Time_offsets_from_UTC
>>
>> 所以麻烦看一看这个问题是否是bug或者是有什么其他方法可以绕过这个问题吧?
>>
>> —
>> You are receiving this because you are subscribed to this thread.
>> Reply to this email directly, view it on GitHub
>> <#2754?email_source=notifications&email_token=AMX2YHMV3K55QHLELBWXM6TQKIGUXA5CNFSM4IX5M3U2YY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4HMDVBWQ>,
>> or mute the thread
>> <https://github.com/notifications/unsubscribe-auth/AMX2YHOM4KI7CM3MWSWVPFDQKIGUXANCNFSM4IX5M3UQ>
>> .
>>
>
|
…as NZ-CHAT / Pacific/Chatham
@Omega-Ariston 你好,我看了下你修复后的代码,限制得比较死,只是单独支持了+12:45时区的反序列化(if(t0 == '1' && t1 == '2' && t3 == '4' && t4 == '5') {}),但实际上,特殊的时区还有+05:45, +08:45,所以避免后面再出现类似问题,麻烦也一并解决下吧?谢谢。 |
嗯嗯,之前看wiki以为只有新西兰时区情况特殊,后来仔细查了下发现还有以下几个:
多谢提醒,一会完善一下 :) |
客气了,另外,我想问下,这个大概会在哪个版本解决呢? |
据我所知,正常情况下master分支里的代码是会和下一个版本一起打包发布 |
好的,感谢支持。:) |
…lete timezone cases completed for #2754
@Omega-Ariston hi, 我又发现两个时区为45分的特殊情况,分别如下,可能需要麻烦你处理下了。 除了上面的+09:45和+13:45,还发现一些特殊的时区,如:-00:44,-00:25:21,+00:20,+01:24,+04:51,+05:40,+07:20等等。 |
我核实下 |
@Omega-Ariston hi 麻烦问下,这个核实有结果了吗? |
你好,我在Java中使用1.2.60的fastjson反序列化如下json时会出现反序列化失败:
待反序列化的Json内容:
"{"p1":"2019-09-18T20:35:00+12:45"}"
用于反序列化的类:
public class C{
public Calendar p1;
}
我看了下fastjson的底层源码,发现是JSONScanner类的第479行代码(scanISO8601DateIfMatch方法中)有个判断if (t3 != '0' && t3 != '3'){return false;}导致的,当时间带时区且时区不是0分或者30分时,就认为不是ISO8601的格式,但实际上的确有些地方的时区是45分,比如新西兰的时区是+12:45,具体可以见下面的wiki:
https://en.wikipedia.org/wiki/List_of_UTC_time_offsets
同时,我看了下ISO8601的wiki,规范中并未限制时区的分钟部分只能是0或者30分,见下wiki:
https://en.wikipedia.org/wiki/ISO_8601#Time_offsets_from_UTC
所以麻烦看一看这个问题是否是bug或者是有什么其他方法可以绕过这个问题吧?
The text was updated successfully, but these errors were encountered: