Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
    Kamil Kloch
    @kamilkloch
    For what it's worth, that's my dirty hack. Comments welcome ;)
    object UPickle extends upickle.AttributeTagged {
        override def tagName: String = "type"
    
      override def annotate[V](rw: CaseR[V], n: String): TaggedReader.Leaf[V] =
        new TaggedReader.Leaf[V](modifyAnnotation(n), rw)
    
      override def annotate[V](rw: CaseW[V], n: String)(implicit c: ClassTag[V]): TaggedWriter.Leaf[V] =
        new TaggedWriter.Leaf[V](c, modifyAnnotation(n), rw)
    
      private def modifyAnnotation(s: String): String = s.toString.reverse.takeWhile(_ != '.').reverse
    }
    Li Haoyi
    @lihaoyi
    looks reasonable
    not sure how it achieves your original goal of not "making it vulnerable to any refactoring" though :P
    i guess you can move packages around
    Andriy Plokhotnyuk
    @plokhotnyuk
    @kamilkloch @lihaoyi What a nice solution! Thanks to both of you! I have tried to do that by overriding of objectTypeKeyReadMap/objectTypeKeyWriteMap but it doesn't allow to refactor package or object namespace... Only one note that the efficiency of modifyAnnotation will be much better after switching to implementation like here.
    Li Haoyi
    @lihaoyi
    haha yes, your implementation will be much faster :P
    Kamil Kloch
    @kamilkloch
    @plokhotnyuk Thanks, stealing your implementation ;)
    Daniel Gordon
    @DanielGGordon
    I added libraryDependencies += "com.lihaoyi" %% "upickle" % "0.7.5" to my project but it does not find the dependency
    sbt.librarymanagement.ResolveException: unresolved dependency: com.lihaoyi#upickle_2.11;0.7.5: not found
    Li Haoyi
    @lihaoyi
    not published for 2.11
    Daniel Gordon
    @DanielGGordon
    oh
    Li Haoyi
    @lihaoyi
    try an older version of upickle?
    those artifacts are still up
    nothing changed
    Daniel Gordon
    @DanielGGordon
    Its ok I got it, I changed project to 2.12.
    Question though - so I have a Value and I want to use the apply function - but I don't want a runtime error if the field doesn't exist
    Is there a nice way I can have something similar to apply, but returns an option?
    Right now I just pass a string that corresponds to the key for the field I am looking for
    Li Haoyi
    @lihaoyi
    you can add your own extension method
    if it works for you and you think others will like it, send a PR and we can discuss merging (or not)
    Daniel Gordon
    @DanielGGordon
    @lihaoyi ah ok so nothing native. Got it. Ok I'll figure it out. Thanks! For now I might just wrap it in a future or something
    but that doesn't really make so much sense
    Daniel Gordon
    @DanielGGordon
    def str = this match{
        case Value.Str(value) => value
        case _ => throw Value.InvalidData(this, "Expected ujson.Str")
      }
    So I would personally want the return type of this to be an option, is what I was thinking. and instead of throwing error, just return None.
    Doug Roper
    @htmldoug

    I can't get mill 0.4.1 to compile the build definition of lihaoyi/upickle:master.

     ~/code/upickle   master  mill -i
    
    Loading...
    Compiling /Users/doug.roper/code/upickle/build.sc
    build.sc:325: not found: value jsEnvConfig
                jsEnvConfig(),
                ^
    build.sc:319: `T.sources` definitions must have 0 parameter lists
        def run(args: String*) = T.command {
            ^
    Compilation Failed

    I'm on latest master (which passes in travis):

     ~/code/upickle   master  git rev-parse HEAD
    
    c2779f24591e4ed33e547dbf1e849368c0322282

    I'm using the brew package of mill:

     ~/code/upickle   master  brew info mill
    mill: stable 0.4.1
    Scala build tool
    https://www.lihaoyi.com/mill/
    /usr/local/Cellar/mill/0.4.1 (4 files, 37.0MB) *
      Built from source on 2019-06-28 at 17:08:52
    From: https://github.com/Homebrew/homebrew-core/blob/master/Formula/mill.rb
    ==> Requirements
    Required: java >= 1.8 ✔
    ==> Analytics
    install: 356 (30 days), 629 (90 days), 2,793 (365 days)
    install_on_request: 357 (30 days), 629 (90 days), 2,781 (365 days)
    build_error: 0 (30 days)

    Which is the correct one on the path:

      ~/code/upickle   master  ll `which mill`
    lrwxr-xr-x  1 doug.roper  admin  29 Jun 28 17:08 [1]  /usr/local/bin/mill -> ../Cellar/mill/0.4.1/bin/mill

    Passing travis build against this commit using mill 0.4.1 indicates something wrong on my side maybe. How can I narrow the problem?

    Also tried a fresh git clone. Same problem.
    Doug Roper
    @htmldoug
    Commenting out https://github.com/lihaoyi/upickle/blob/master/build.sc#L315-L331 seems like a successful workaround.
    Li Haoyi
    @lihaoyi
    try the mill master build?
    there are binaries you can download on the releases pagr
    Doug Roper
    @htmldoug
    whoa, works. Didn't occur to me that it required an unreleased mill version.
    thanks
    Li Haoyi
    @lihaoyi
    haha yeah
    i should go tag a release
    Justin du Coeur, AKA Mark Waks
    @jducoeur
    @lihaoyi Howdy! I'm currently looking at pulling in upickle to replace Play-JSON for serialization in a bunch of our libraries, in order to reduce our Play-version-dependency footprint and because, hey, it's a good library.
    Food for thought: part of why I'm doing this is because of Version Hell: all those Play-JSON dependencies make it harder for us to upgrade our Play version in our services, since it requires upgrading all of the libraries in sync. I'm a little concerned about us winding up with upickle version clashes between libraries, though.
    Any chance you would consider shading upickle in some fashion? It would make life easier for large groups like mine, which potentially have lots of different libraries using it.
    (Not a demand, by any means -- I'm just trying to figure out how we should deal with this problem internally.)
    Doug Roper
    @htmldoug
    ^ I'm also interested in having a json library that my own libraries can use/depend on without causing binary incompatible evictions for my downstream users.
    Best I can come up with is forking uPickle, renaming the packages, and putting MiMa in front of it to freeze the APIs until another package rename.
    I'd love a better solution though.
    Li Haoyi
    @lihaoyi
    shading normally happens as late as possible
    so e.g. if you want to use upickle and it’s causing conflicts in your project, then your project does the shading
    using jarjar or whatever
    it’s not common for upstream projects to publish shaded versions of themselves, because shading often involves entire dependency subtrees rather than any single project
    Doug Roper
    @htmldoug
    I think the problem will be macros
    Hariharan Thiagarajan
    @thari
    Any idea why I am getting java.lang.ClassCastException: upickle.core.Types$ReadWriter$$anon$3 cannot be cast to upickle.core.Types$TaggedReadWriter
    Li Haoyi
    @lihaoyi
    sounds like you have two incompatible versions of upickle living in the same classpath
    Hariharan Thiagarajan
    @thari
    Thanks, I am not sure if that was the reason. I added sealed to my trait and moved my class to same file. I am using uPickle 0.7.1
    Sotiris Tzamaras
    @sotostzam
    Hi, i am using ujson within a scala application and i came across to the following issue. I am trying to create a json from a table. So i use val jsonFormat = ujson.Arr()and then dynamically i am creating multiple ujson.Obj() with the command xx.obj.put(stuff here). When every row ends i call jsonName.arr.append(xx) and then xx.obj.clear() as i want it to be empty for the next row. Now what happens is it actually clears this obj as well as anything already appended into my array. So end with something like this: [ { }, { }, { } ]. What am i doing wrong here?
    Andriy Plokhotnyuk
    @plokhotnyuk
    @sotostzam Hi, Sotiris! Could you please paste the code from Scala REPL or Ammonite/sbt console to reproduce a problem?
    Sotiris Tzamaras
    @sotostzam
    @plokhotnyuk Hey! I managed to make it work by appending the obj.value and not the object itself. So now it works flawlessly.