Skip to content

Commit

Permalink
documentation tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed Jul 16, 2013
1 parent dd5b9e4 commit 2a3b3a4
Showing 1 changed file with 5 additions and 11 deletions.
16 changes: 5 additions & 11 deletions lib/Mojo/JSON.pm
Expand Up @@ -353,21 +353,15 @@ it for validation.
It supports normal Perl data types like C<Scalar>, C<Array> reference, C<Hash>
reference and will try to call the C<TO_JSON> method on blessed references, or
stringify them if it doesn't exist.
stringify them if it doesn't exist. Differentiating between strings and
numbers in Perl is hard, depending on how it has been used, a C<Scalar> can be
both at the same time. Since numeric comparisons on strings are very unlikely
to happen intentionally, the numeric value always gets priority, so any
C<Scalar> that has been used in numeric context is considered a number.
[1, -2, 3] -> [1, -2, 3]
{"foo": "bar"} -> {foo => 'bar'}
Differentiating between strings and numbers in Perl is hard, depending on how
it has been used, a C<Scalar> can be both at the same time. Since numeric
comparisons for strings are very unlikely to happen intentionally, the numeric
value always gets priority, so any C<Scalar> that has been used in numeric
context is considered a number.
23 -> 23
"23" -> "23"
"2" + "3" -> 5
Literal names will be translated to and from L<Mojo::JSON> constants or a
similar native Perl value. In addition C<Scalar> references will be used to
generate booleans, based on if their values are true or false.
Expand Down

0 comments on commit 2a3b3a4

Please sign in to comment.