µPickle is a lightweight serialization library for Scala and ScalaJS.
Questions tagged [upickle]
43 questions
1
vote
1 answer
How to have a generic solution to parse an unknown class to Json in scalaJs
I'm using ScalaJs angular and Upickle and I try to create a filter to transform an unknown class to JSON.
What I tried :
my scope :
var myScope: MyClass = js.native
my filter:
@injectable("copy")
class CopyFilter extends Filter[Any] {
…

Loann Delgado
- 187
- 1
- 9
1
vote
1 answer
Minimal example for autowire and upickle
I am not quite getting how the minimal example can be applied to my web app.
In the client code I override the doCall method:
override def doCall(req: Request) = {
println(req)
MyServer.routes.apply(req)
}
But how can the client know about…

Klaus Schulz
- 527
- 1
- 5
- 20
1
vote
1 answer
Serialisation/deserialisation for sealed traits with Upickle
I am trying to call a webservice from my play server I am using upickle for serialisation/deserialisation . My problem I have a sealed trait as
sealed trait RequestContent {
}
case class CreateUserRequest (email: String, password: String,jsonBlob:…
user4833870
1
vote
0 answers
ScalaJS: how to parse ajax response from JSON to a case class
I'm trying ScalaJS with Play! Scala 2.4 and the serialization library for Scala uPickle.
I don't manage to parse the return of an AJAX call.
Here is my case class:
@JSExportAll
case class Room(id: String, name: String, presentation: String, images:…

Simon
- 6,025
- 7
- 46
- 98
1
vote
1 answer
How to married scalajs-react and autowire on a client side?
I have trouble to mix autowire calls with scalajs-react components. Here is a simple example using scalajs-react v0.10.0 + autowire v0.2.5
case class User(name: String)
class Backend($: BackendScope[Unit, User]) {
def mounted: Callback = {
…

falcon
- 372
- 3
- 19
1
vote
0 answers
Cannot get upickle working with scala.js in a scalatra servlet
When I try calling upickle.write from anywhere in a servlet I get an exception. If for example I do
upickle.write("x")
I get the exception below. Any suggestions?
java.lang.ClassCastException: java.lang.String cannot be cast to…

user79074
- 4,937
- 5
- 29
- 57
0
votes
0 answers
_pickle.UnpicklingError: A load persistent id instruction was encountered, but no persistent_load function was specified
when i wanna convert pkl model to pth model I receive an error and don’t know how to solve it.
here is my code:
import pickle
import sys
from enum import Enum
from pathlib import Path
from typing import Optional
import torch
checkpoint_path =…

sara asadi
- 1
- 1
0
votes
0 answers
Using uPickle, how do I instantiate a case class from a JSON array of different number types?
I have an array in JSON that looks like this:
"[3.7434,23.4308,3,131.45,1687,1436,1680195035745932326,-13.5,7,11,0.18,1]"
I want to create out of that array a instance of a case class that has the following…

gknauth
- 2,310
- 2
- 29
- 44
0
votes
1 answer
Cannot resolve symbol foreach in Scala
I have a data with Map Structure. I want to iterate on the data and extract a list of keys with special values. I wrote the below code:
val jsonString = os.read(os.pwd/"src"/"main"/"scala"/"config.json")
val data = ujson.read(jsonString)
for ((k,v)…

M_Gh
- 1,046
- 4
- 17
- 43
0
votes
0 answers
Getting an error while loading pickled spacy NER Model?
with open ("path/nlp_ner_model.p",'rb') as f:
ner = pickle.load(f)
I am using the above code and getting an error:
Can't get attribute 'default_serialize_torch_model' on

Arun Vijay
- 39
- 5
0
votes
1 answer
Scala 2.13: Case class with extendable variable attributes?
I want to create a case class which can incorporate a record of string and another case class entity.
For example:
case class Student(
name: String
age: Int
)
case class Example(
[key:String]: Student
)
Now I want to use Example to add multiple…

Shivam Sahil
- 4,055
- 3
- 31
- 62
0
votes
1 answer
scala ujson.read() returns ujson.Obj
I am trying to read a json string using Li Haoyi's ujson. This is the string:
{
"dataflows": [
{
"name": "test",
"sources": [
{
"name": "person_inputs",
"path": "/data/input/events/person/*",
…

MrMuppet
- 547
- 1
- 4
- 12
0
votes
1 answer
Idiomatic handling of JSON null in scala upickle / ujson
I am new to Scala and would like to learn the idiomatic way to solve common problems, as in pythonic for Python. My question regards reading JSON data with upickle, where the JSON value contains a string when present, and null when not present. I…

LukeL
- 28
- 5
0
votes
2 answers
Extra bytes being added to serialization with BooPickle and RocksDb
So I'm using BooPickle to serialize Scala classes before writing them to RocksDB. To serialize a class,
case class Key(a: Long, b: Int) {
def toStringEncoding: String = s"${a}-${b}"
}
I have this implicit class
implicit class KeySerializer(key:…

mdornfe1
- 1,982
- 1
- 24
- 42
0
votes
2 answers
Is it possible to write a upickle Serializer for akka
I would like to implement an akka Serializer using upickle but I'm not sure its possible. To do so I would need to implement a Serializer something like the following:
import akka.serialization.Serializer
import upickle.default._
class…

user79074
- 4,937
- 5
- 29
- 57