Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add sortKeys: Boolean flag to ujson/upickle APIs #553

Merged
merged 8 commits into from
Feb 9, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions ujson/src/ujson/IndexedValue.scala
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ import upickle.core.{Visitor, ObjVisitor, ArrVisitor, Abort, AbortException}
* want to work with an AST but still provide source-index error positions if
* something goes wrong
*/
@deprecated("Left for binary compatibility, use upickle.core.BufferedValue instead")
@deprecated("Left for binary compatibility, use upickle.core.BufferedValue instead", "After 3.1.4")
sealed trait IndexedValue {
def index: Int
}

@deprecated("Left for binary compatibility, use upickle.core.BufferedValue instead")
@deprecated("Left for binary compatibility, use upickle.core.BufferedValue instead", "After 3.1.4")
object IndexedValue extends Transformer[IndexedValue]{

case class Str(index: Int, value0: java.lang.CharSequence) extends IndexedValue
Expand Down
16 changes: 15 additions & 1 deletion ujson/src/ujson/package.scala
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ package object ujson{
BufferedValue.maybeSortKeysTransform(Readable, t, sortKeys, v)
}

// @deprecated("Binary Compatibility Stub", "After 3.1.4")
def transform[T](t: Readable,
v: upickle.core.Visitor[_, T]): T = transform(t, v, sortKeys = false)
/**
Expand All @@ -29,6 +30,8 @@ package object ujson{
writeTo(t, writer, indent, escapeUnicode, sortKeys)
writer.toString
}

// @deprecated("Binary Compatibility Stub", "After 3.1.4")
def write(t: Value.Value,
indent: Int,
escapeUnicode: Boolean): String = {
Expand All @@ -45,11 +48,13 @@ package object ujson{
sortKeys: Boolean = false): Unit = {
transform(t, Renderer(out, indent, escapeUnicode), sortKeys)
}

// @deprecated("Binary Compatibility Stub", "After 3.1.4")
def writeTo(t: Value.Value,
out: java.io.Writer,
indent: Int,
escapeUnicode: Boolean): Unit = {
writeTo(t, out, indent, escapeUnicode, sortKeys=false)
writeTo(t, out, indent, escapeUnicode, sortKeys = false)
}

def writeToOutputStream(t: Value.Value,
Expand All @@ -60,6 +65,7 @@ package object ujson{
transform(t, new BaseByteRenderer(out, indent, escapeUnicode), sortKeys)
}

// @deprecated("Binary Compatibility Stub", "After 3.1.4")
def writeToOutputStream(t: Value.Value,
out: java.io.OutputStream,
indent: Int,
Expand All @@ -76,6 +82,7 @@ package object ujson{
baos.toByteArray
}

// @deprecated("Binary Compatibility Stub", "After 3.1.4")
def writeToByteArray(t: Value.Value,
indent: Int,
escapeUnicode: Boolean): Array[Byte] = {
Expand All @@ -98,6 +105,8 @@ package object ujson{
reformatTo(s, writer, indent, escapeUnicode, sortKeys)
writer.toString
}

// @deprecated("Binary Compatibility Stub", "After 3.1.4")
def reformat(s: Readable,
indent: Int,
escapeUnicode: Boolean): String = {
Expand All @@ -114,6 +123,8 @@ package object ujson{
sortKeys: Boolean = false): Unit = {
transform(s, Renderer(out, indent, escapeUnicode), sortKeys)
}

// @deprecated("Binary Compatibility Stub", "After 3.1.4")
def reformatTo(s: Readable,
out: java.io.Writer,
indent: Int,
Expand All @@ -131,6 +142,8 @@ package object ujson{
sortKeys: Boolean = false): Unit = {
transform(s, new BaseByteRenderer(out, indent, escapeUnicode), sortKeys)
}

// @deprecated("Binary Compatibility Stub", "After 3.1.4")
def reformatToOutputStream(s: Readable,
out: java.io.OutputStream,
indent: Int,
Expand All @@ -147,6 +160,7 @@ package object ujson{
baos.toByteArray
}

// @deprecated("Binary Compatibility Stub", "After 3.1.4")
def reformatToByteArray(s: Readable,
indent: Int,
escapeUnicode: Boolean): Array[Byte] = {
Expand Down
20 changes: 11 additions & 9 deletions upickle/src/upickle/Api.scala
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ trait Api
maybeSortKeysTransform(t, sortKeys, ujson.StringRenderer(indent, escapeUnicode)).toString
}

// Binary Compatibility Stub
// @deprecated("Binary Compatibility Stub", "After 3.1.4")
def write[T: Writer](t: T,
indent: Int,
escapeUnicode: Boolean): String = {
Expand All @@ -69,7 +69,7 @@ trait Api
maybeSortKeysTransform(t, sortKeys, new upack.MsgPackWriter(new ByteArrayOutputStream())).toByteArray
}

// Binary Compatibility Stub
// @deprecated("Binary Compatibility Stub", "After 3.1.4")
def writeBinary[T: Writer](t: T): Array[Byte] = writeBinary(t, sortKeys = false)

/**
Expand All @@ -93,7 +93,8 @@ trait Api
maybeSortKeysTransform(t, sortKeys, new ujson.Renderer(out, indent = indent, escapeUnicode))
}

// Binary Compatibility Stub

// @deprecated("Binary Compatibility Stub", "After 3.1.4")
def writeTo[T: Writer](t: T,
out: java.io.Writer,
indent: Int,
Expand All @@ -107,7 +108,7 @@ trait Api
maybeSortKeysTransform(t, sortKeys, new ujson.BaseByteRenderer(out, indent = indent, escapeUnicode))
}

// Binary Compatibility Stub
// @deprecated("Binary Compatibility Stub", "After 3.1.4")
def writeToOutputStream[T: Writer](t: T,
out: java.io.OutputStream,
indent: Int,
Expand All @@ -124,7 +125,7 @@ trait Api
out.toByteArray
}

// Binary Compatibility Stub
// @deprecated("Binary Compatibility Stub", "After 3.1.4")
def writeToByteArray[T: Writer](t: T,
indent: Int,
escapeUnicode: Boolean): Array[Byte] = {
Expand All @@ -143,7 +144,7 @@ trait Api
}
}

// Binary Compatibility Stub
// @deprecated("Binary Compatibility Stub", "After 3.1.4")
def stream[T: Writer](t: T,
indent: Int,
escapeUnicode: Boolean): geny.Writable = {
Expand All @@ -157,7 +158,8 @@ trait Api
sortKeys: Boolean = false): Unit = {
streamBinary[T](t, sortKeys = sortKeys).writeBytesTo(out)
}
// Binary Compatibility Stub

// @deprecated("Binary Compatibility Stub", "After 3.1.4")
def writeBinaryTo[T: Writer](t: T,
out: java.io.OutputStream): Unit = {
writeBinaryTo(t, out, sortKeys = false)
Expand All @@ -170,7 +172,7 @@ trait Api
out.toByteArray
}

// Binary Compatibility Stub
// @deprecated("Binary Compatibility Stub", "After 3.1.4")
def writeBinaryToByteArray[T: Writer](t: T): Array[Byte] = {
writeBinaryToByteArray(t, sortKeys = false)
}
Expand All @@ -182,7 +184,7 @@ trait Api
def writeBytesTo(out: java.io.OutputStream) = maybeSortKeysTransform(t, sortKeys, new upack.MsgPackWriter(out))
}

// Binary Compatibility Stub
// @deprecated("Binary Compatibility Stub", "After 3.1.4")
def streamBinary[T: Writer](t: T): geny.Writable = {
streamBinary(t, sortKeys = false)
}
Expand Down
Loading