Skip to content

Commit 38ac056

Browse files
authored
Remove deprecations in prep for 4.x, break out Config trait and update docs (#599)
We disable MIMA checking, because we expect 4.x to be a binary incompatible change. This gives us the opportunity to clean up a year's worth of backwards compatibility stubs
1 parent a871efb commit 38ac056

File tree

12 files changed

+88
-489
lines changed

12 files changed

+88
-489
lines changed

build.sc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ trait CommonPublishModule
4646

4747
def publishVersion = VcsVersion.vcsState().format()
4848
def mimaReportBinaryIssues() =
49-
if (this.isInstanceOf[ScalaNativeModule] || this.isInstanceOf[ScalaJSModule]) T.command()
49+
if (true || this.isInstanceOf[ScalaNativeModule] || this.isInstanceOf[ScalaJSModule]) T.command()
5050
else super.mimaReportBinaryIssues()
5151

5252
def mimaPreviousVersions = Seq(

ujson/src/ujson/IndexedValue.scala

Lines changed: 0 additions & 94 deletions
This file was deleted.

ujson/src/ujson/package.scala

Lines changed: 3 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,6 @@ package object ujson{
88
BufferedValue.maybeSortKeysTransform(Readable, t, sortKeys, v)
99
}
1010

11-
// @deprecated("Binary Compatibility Stub", "upickle after 3.1.4")
12-
def transform[T](t: Readable,
13-
v: upickle.core.Visitor[_, T]): T = transform(t, v, sortKeys = false)
1411
/**
1512
* Read the given JSON input as a JSON struct
1613
*/
@@ -31,13 +28,6 @@ package object ujson{
3128
writer.toString
3229
}
3330

34-
// @deprecated("Binary Compatibility Stub", "upickle after 3.1.4")
35-
def write(t: Value.Value,
36-
indent: Int,
37-
escapeUnicode: Boolean): String = {
38-
write(t, indent, escapeUnicode, sortKeys = false)
39-
}
40-
4131
/**
4232
* Write the given JSON struct as a JSON String to the given Writer
4333
*/
@@ -49,14 +39,6 @@ package object ujson{
4939
transform(t, Renderer(out, indent, escapeUnicode), sortKeys)
5040
}
5141

52-
// @deprecated("Binary Compatibility Stub", "upickle after 3.1.4")
53-
def writeTo(t: Value.Value,
54-
out: java.io.Writer,
55-
indent: Int,
56-
escapeUnicode: Boolean): Unit = {
57-
writeTo(t, out, indent, escapeUnicode, sortKeys = false)
58-
}
59-
6042
def writeToOutputStream(t: Value.Value,
6143
out: java.io.OutputStream,
6244
indent: Int = -1,
@@ -65,14 +47,6 @@ package object ujson{
6547
transform(t, new BaseByteRenderer(out, indent, escapeUnicode), sortKeys)
6648
}
6749

68-
// @deprecated("Binary Compatibility Stub", "upickle after 3.1.4")
69-
def writeToOutputStream(t: Value.Value,
70-
out: java.io.OutputStream,
71-
indent: Int,
72-
escapeUnicode: Boolean): Unit = {
73-
writeToOutputStream(t, out, indent, escapeUnicode, sortKeys = false)
74-
}
75-
7650
def writeToByteArray(t: Value.Value,
7751
indent: Int = -1,
7852
escapeUnicode: Boolean = false,
@@ -82,13 +56,6 @@ package object ujson{
8256
baos.toByteArray
8357
}
8458

85-
// @deprecated("Binary Compatibility Stub", "upickle after 3.1.4")
86-
def writeToByteArray(t: Value.Value,
87-
indent: Int,
88-
escapeUnicode: Boolean): Array[Byte] = {
89-
writeToByteArray(t, indent, escapeUnicode, sortKeys = false)
90-
}
91-
9259
/**
9360
* Parse the given JSON input, failing if it is invalid
9461
*/
@@ -105,13 +72,7 @@ package object ujson{
10572
reformatTo(s, writer, indent, escapeUnicode, sortKeys)
10673
writer.toString
10774
}
108-
109-
// @deprecated("Binary Compatibility Stub", "upickle after 3.1.4")
110-
def reformat(s: Readable,
111-
indent: Int,
112-
escapeUnicode: Boolean): String = {
113-
reformat(s, indent, escapeUnicode, sortKeys = false)
114-
}
75+
11576
/**
11677
* Parse the given JSON input and write it to a string with
11778
* the configured formatting to the given Writer
@@ -123,14 +84,7 @@ package object ujson{
12384
sortKeys: Boolean = false): Unit = {
12485
transform(s, Renderer(out, indent, escapeUnicode), sortKeys)
12586
}
126-
127-
// @deprecated("Binary Compatibility Stub", "upickle after 3.1.4")
128-
def reformatTo(s: Readable,
129-
out: java.io.Writer,
130-
indent: Int,
131-
escapeUnicode: Boolean): Unit = {
132-
reformatTo(s, out, indent, escapeUnicode, sortKeys = false)
133-
}
87+
13488
/**
13589
* Parse the given JSON input and write it to a string with
13690
* the configured formatting to the given Writer
@@ -142,15 +96,7 @@ package object ujson{
14296
sortKeys: Boolean = false): Unit = {
14397
transform(s, new BaseByteRenderer(out, indent, escapeUnicode), sortKeys)
14498
}
145-
146-
// @deprecated("Binary Compatibility Stub", "upickle after 3.1.4")
147-
def reformatToOutputStream(s: Readable,
148-
out: java.io.OutputStream,
149-
indent: Int,
150-
escapeUnicode: Boolean): Unit = {
151-
reformatToOutputStream(s, out, indent, escapeUnicode, sortKeys = false)
152-
}
153-
99+
154100
def reformatToByteArray(s: Readable,
155101
indent: Int = -1,
156102
escapeUnicode: Boolean = false,
@@ -159,16 +105,4 @@ package object ujson{
159105
reformatToOutputStream(s, baos, indent, escapeUnicode, sortKeys)
160106
baos.toByteArray
161107
}
162-
163-
// @deprecated("Binary Compatibility Stub", "upickle after 3.1.4")
164-
def reformatToByteArray(s: Readable,
165-
indent: Int,
166-
escapeUnicode: Boolean): Array[Byte] = {
167-
reformatToByteArray(s, indent, escapeUnicode, sortKeys = false)
168-
}
169-
// End ujson
170-
@deprecated("use ujson.Value")
171-
type Js = Value
172-
@deprecated("use ujson.Value")
173-
val Js = Value
174108
}

upack/src/upack/MsgPackWriter.scala

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -320,17 +320,4 @@ class MsgPackWriter[T <: java.io.OutputStream](out: T = new ByteArrayOutputStrea
320320
flushElemBuilder()
321321
out
322322
}
323-
324-
325-
@deprecated("Not used, kept for binary compatibility")
326-
def writeUInt8(i: Int): Unit = writeUInt8(byteBuilder.arr, byteBuilder.length, i)
327-
328-
@deprecated("Not used, kept for binary compatibility")
329-
def writeUInt16(i: Int): Unit = writeUInt16(byteBuilder.arr, byteBuilder.length, i)
330-
331-
@deprecated("Not used, kept for binary compatibility")
332-
def writeUInt32(i: Int): Unit = writeUInt32(byteBuilder.arr, byteBuilder.length, i)
333-
334-
@deprecated("Not used, kept for binary compatibility")
335-
def writeUInt64(i: Long): Unit = writeUInt64(byteBuilder.arr, byteBuilder.length, i)
336323
}
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
package upickle.core
2+
3+
// Common things for derivation
4+
trait Config {
5+
def tagName = Annotator.defaultTagKey
6+
/**
7+
* Whether to use the fully-qualified name of `case class`es and `case object`s which
8+
* are part of `sealed trait` hierarchies when serializing them and writing their `$type`
9+
* key. Defaults to `false`, so `$type` key uses the shortest partially-qualified name.
10+
* Can be set to `true` to use their fully-qualified name.
11+
*/
12+
def objectTypeKeyWriteFullyQualified: Boolean = false
13+
14+
/**
15+
* Whether or not to write `case class` keys which match their default values.
16+
* Defaults to `false`, allowing those keys to be omitted. Can be set to `true`
17+
* to always write field values even if they are equal to the default
18+
*/
19+
def serializeDefaults: Boolean = false
20+
21+
/**
22+
* Transform dictionary keys when writing `case class`es when reading. Can
23+
* be overriden to provide custom mappings between Scala field names and JSON
24+
* field names. Needs to be kept in sync with [[objectAttributeKeyWriteMap]]
25+
*
26+
* This customizes the mapping across all `case class`es fields handled by this
27+
* upickle instance. This can be customized on a field-by-field basis using the
28+
* [[upickle.implicits.key]] annotation on the `case class` field
29+
*/
30+
def objectAttributeKeyReadMap(s: CharSequence): CharSequence = s
31+
32+
/**
33+
* Map the name of JSON object fields to Scala `case class` fields during serialization.
34+
* Must be kept in sync with [[objectAttributeKeyReadMap]]
35+
*/
36+
def objectAttributeKeyWriteMap(s: CharSequence): CharSequence = s
37+
38+
/**
39+
* Transforms the value of the `$type` field when writing `sealed trait`s,
40+
* to allow custom mapping between the `case class` name and the `$type` field
41+
* in the generated JSON. Must be kept in sync with [[objectTypeKeyWriteMap]].
42+
*
43+
* * This customizes the mapping across all `case class`es fields handled by this
44+
* * upickle instance. This can be customized on a per-`sealed trait` basis using the
45+
* * [[upickle.implicits.key]] annotation on the `case class`
46+
*/
47+
def objectTypeKeyReadMap(s: CharSequence): CharSequence = s
48+
49+
/**
50+
* Map the name of Scala `case class` type names to JSON `$type` field value during
51+
* serialization. Must be kept in sync with [[objectTypeKeyReadMap]]
52+
*/
53+
def objectTypeKeyWriteMap(s: CharSequence): CharSequence = s
54+
55+
/**
56+
* Whether top-level `Some(t)`s and `None`s are serialized unboxed as `t` or
57+
* `null`, rather than `[t]` or `[]`. This is generally what people expect,
58+
* although it does cause issues where `Some(null)` when serialized and de-serialized
59+
* can become `None`. Can be disabled to use the boxed serialization format
60+
* as 0-or-1-element-arrays, presering round trip-ability at the expense of
61+
* un-intuitiveness and verbosity
62+
*/
63+
def optionsAsNulls: Boolean = true
64+
}

upickle/core/src/upickle/core/RenderUtils.scala

Lines changed: 0 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -70,18 +70,6 @@ object RenderUtils{
7070
if (wrapQuotes) sb.append('"')
7171
}
7272

73-
@deprecated("Not used, kept for binary compatibility")
74-
def escapeSingleByteUnicodeRaw(unicodeCharBuilder: CharBuilder,
75-
sb: ByteBuilder,
76-
s: CharSequence,
77-
escapeUnicode: Boolean,
78-
i0: Int,
79-
len0: Int,
80-
naiveOutLen: Int,
81-
wrapQuotes: Boolean): Unit = escapeSingleByteUnicodeRaw(
82-
unicodeCharBuilder, sb, s, escapeUnicode, i0, len0, wrapQuotes
83-
)
84-
8573
def escapeSingleByteUnicodeRaw(unicodeCharBuilder: CharBuilder,
8674
sb: ByteBuilder,
8775
s: CharSequence,
@@ -224,37 +212,4 @@ object RenderUtils{
224212
}
225213
19 + d
226214
}
227-
228-
@deprecated("Not used, kept for binary compatibility")
229-
def escapeSingleChar(sb: upickle.core.CharBuilder,
230-
naiveOutLen: Int,
231-
i: Int,
232-
c: Char) = CharUtils.escapeSingleChar(sb, i, c)
233-
234-
@deprecated("Not used, kept for binary compatibility")
235-
def escapeSingleByte(sb: upickle.core.ByteBuilder,
236-
naiveOutLen: Int,
237-
i: Int,
238-
c: Char) = ByteUtils.escapeSingleByte(sb, i, c)
239-
240-
@deprecated("Not used, kept for binary compatibility")
241-
def escapeSingleCharUnicodeEscape(naiveOutLen: Int, sb: CharBuilder, i: Int, c: Char) =
242-
CharUtils.escapeSingleCharUnicodeEscape(sb, i, c)
243-
244-
@deprecated("Not used, kept for binary compatibility")
245-
def escapeSingleByteUnicodeEscape(sb: ByteBuilder, i: Int, naiveOutLen: Int, c: Char) = {
246-
ByteUtils.escapeSingleByteUnicodeEscape(sb, i, c)
247-
}
248-
249-
@deprecated("Not used, kept for binary compatibility")
250-
final def escapeChar0(i0: Int,
251-
naiveOutLen: Int,
252-
len: Int,
253-
sb: upickle.core.CharBuilder,
254-
s: CharSequence,
255-
escapeUnicode: Boolean,
256-
wrapQuotes: Boolean): upickle.core.CharBuilder = {
257-
escapeChar0(i0, len, sb, s, escapeUnicode, wrapQuotes)
258-
}
259-
260215
}

0 commit comments

Comments
 (0)