File tree 10 files changed +636
-7
lines changed
10 files changed +636
-7
lines changed Original file line number Diff line number Diff line change @@ -146,6 +146,16 @@ final class JNumber private[ast] (val value: String) extends JValue {
146
146
case jNumberRegex(_ * ) => new JNumber (value)
147
147
case _ => throw new NumberFormatException (value)
148
148
}
149
+
150
+ def toInt : Option [Int ] = scalajson.ast.toInt(value)
151
+
152
+ def toBigInt : Option [BigInt ] = scalajson.ast.toBigInt(value)
153
+
154
+ def toLong : Option [Long ] = scalajson.ast.toLong(value)
155
+
156
+ def toDouble : Option [Double ] = scalajson.ast.toDouble(value)
157
+
158
+ def toBigDecimal : Option [BigDecimal ] = scalajson.ast.toBigDecimal(value)
149
159
}
150
160
151
161
/** Represents a JSON Boolean value, which can either be a
Original file line number Diff line number Diff line change @@ -100,6 +100,16 @@ final case class JNumber(value: String) extends JValue {
100
100
case n if n.isInfinity => null
101
101
case n => n
102
102
}
103
+
104
+ def toInt : Option [Int ] = scalajson.ast.toInt(value)
105
+
106
+ def toBigInt : Option [BigInt ] = scalajson.ast.toBigInt(value)
107
+
108
+ def toLong : Option [Long ] = scalajson.ast.toLong(value)
109
+
110
+ def toDouble : Option [Double ] = scalajson.ast.toDouble(value)
111
+
112
+ def toBigDecimal : Option [BigDecimal ] = scalajson.ast.toBigDecimal(value)
103
113
}
104
114
105
115
/** Represents a JSON Boolean value, which can either be a
Original file line number Diff line number Diff line change @@ -98,13 +98,6 @@ object JNumber {
98
98
*/
99
99
final case class JNumber private [ast] (value : String ) extends JValue {
100
100
101
- /**
102
- * Javascript specification for numbers specify a [[scala.Double ]], so this is the default export method to `Javascript`
103
- *
104
- * @param value
105
- */
106
- def this (value : Double ) = this (value.toString)
107
-
108
101
override def toUnsafe : unsafe.JValue = unsafe.JNumber (value)
109
102
110
103
override def toJsAny : js.Any = value.toDouble match {
@@ -128,6 +121,16 @@ final case class JNumber private[ast] (value: String) extends JValue {
128
121
case jNumberRegex(_ * ) => new JNumber (value)
129
122
case _ => throw new NumberFormatException (value)
130
123
}
124
+
125
+ def toInt : Option [Int ] = scalajson.ast.toInt(value)
126
+
127
+ def toBigInt : Option [BigInt ] = scalajson.ast.toBigInt(value)
128
+
129
+ def toLong : Option [Long ] = scalajson.ast.toLong(value)
130
+
131
+ def toDouble : Option [Double ] = scalajson.ast.toDouble(value)
132
+
133
+ def toBigDecimal : Option [BigDecimal ] = scalajson.ast.toBigDecimal(value)
131
134
}
132
135
133
136
/** Represents a JSON Boolean value, which can either be a
Original file line number Diff line number Diff line change @@ -98,6 +98,16 @@ final case class JNumber(value: String) extends JValue {
98
98
case n if n.isInfinity => null
99
99
case n => n
100
100
}
101
+
102
+ def toInt : Option [Int ] = scalajson.ast.toInt(value)
103
+
104
+ def toBigInt : Option [BigInt ] = scalajson.ast.toBigInt(value)
105
+
106
+ def toLong : Option [Long ] = scalajson.ast.toLong(value)
107
+
108
+ def toDouble : Option [Double ] = scalajson.ast.toDouble(value)
109
+
110
+ def toBigDecimal : Option [BigDecimal ] = scalajson.ast.toBigDecimal(value)
101
111
}
102
112
103
113
/** Represents a JSON Boolean value, which can either be a
Original file line number Diff line number Diff line change @@ -125,6 +125,16 @@ final class JNumber private[ast] (val value: String) extends JValue {
125
125
case jNumberRegex(_ * ) => new JNumber (value)
126
126
case _ => throw new NumberFormatException (value)
127
127
}
128
+
129
+ def toInt : Option [Int ] = scalajson.ast.toInt(value)
130
+
131
+ def toBigInt : Option [BigInt ] = scalajson.ast.toBigInt(value)
132
+
133
+ def toLong : Option [Long ] = scalajson.ast.toLong(value)
134
+
135
+ def toDouble : Option [Double ] = scalajson.ast.toDouble(value)
136
+
137
+ def toBigDecimal : Option [BigDecimal ] = scalajson.ast.toBigDecimal(value)
128
138
}
129
139
130
140
/** Represents a JSON Boolean value, which can either be a
Original file line number Diff line number Diff line change @@ -76,6 +76,16 @@ final case class JNumber(value: String) extends JValue {
76
76
case jNumberRegex(_ * ) => new ast.JNumber (value)
77
77
case _ => throw new NumberFormatException (value)
78
78
}
79
+
80
+ def toInt : Option [Int ] = scalajson.ast.toInt(value)
81
+
82
+ def toBigInt : Option [BigInt ] = scalajson.ast.toBigInt(value)
83
+
84
+ def toLong : Option [Long ] = scalajson.ast.toLong(value)
85
+
86
+ def toDouble : Option [Double ] = scalajson.ast.toDouble(value)
87
+
88
+ def toBigDecimal : Option [BigDecimal ] = scalajson.ast.toBigDecimal(value)
79
89
}
80
90
81
91
/** Represents a JSON Boolean value, which can either be a
Original file line number Diff line number Diff line change @@ -106,6 +106,16 @@ final case class JNumber private[ast] (value: String) extends JValue {
106
106
case jNumberRegex(_ * ) => new JNumber (value)
107
107
case _ => throw new NumberFormatException (value)
108
108
}
109
+
110
+ def toInt : Option [Int ] = scalajson.ast.toInt(value)
111
+
112
+ def toBigInt : Option [BigInt ] = scalajson.ast.toBigInt(value)
113
+
114
+ def toLong : Option [Long ] = scalajson.ast.toLong(value)
115
+
116
+ def toDouble : Option [Double ] = scalajson.ast.toDouble(value)
117
+
118
+ def toBigDecimal : Option [BigDecimal ] = scalajson.ast.toBigDecimal(value)
109
119
}
110
120
111
121
/** Represents a JSON Boolean value, which can either be a
Original file line number Diff line number Diff line change @@ -76,6 +76,16 @@ final case class JNumber(value: String) extends JValue {
76
76
case jNumberRegex(_ * ) => new ast.JNumber (value)
77
77
case _ => throw new NumberFormatException (value)
78
78
}
79
+
80
+ def toInt : Option [Int ] = scalajson.ast.toInt(value)
81
+
82
+ def toBigInt : Option [BigInt ] = scalajson.ast.toBigInt(value)
83
+
84
+ def toLong : Option [Long ] = scalajson.ast.toLong(value)
85
+
86
+ def toDouble : Option [Double ] = scalajson.ast.toDouble(value)
87
+
88
+ def toBigDecimal : Option [BigDecimal ] = scalajson.ast.toBigDecimal(value)
79
89
}
80
90
81
91
/** Represents a JSON Boolean value, which can either be a
You can’t perform that action at this time.
0 commit comments