問題タブ [circe]
For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.
json - Circe を使用して JSON 配列をケース クラスとして解析する
この JSON の例を使用してみましょう。
特別なことは何もありません。実際、これは単純にケース クラスに解析できます。
これはうまくいきます...
問題
実際には、すべての配列のサイズが 2 になることを知っています。
- 最初の要素 -> 「レート」です
- 2番目の要素 - >それは「量」です
Circe
これを修正して、次のようなクラス構造に解析したいと思います。
Encoder と Decoder を書いてみました:
しかし、それは常にエラーで失敗します:
なんで?私は何を間違っていますか?
json - jackson-module-scala serialize/deserialize Long keys in Map as Strings
Using jackson-module-Scala, I try to serialize and deserialize an object with an inner Map using a Long as key, but the Jackson serializes the key as String and doesn't deserialize it as Long ifgnoring the type efined in the Class. Is it a BUG? Am I doing something wrong?
The assert fails and the output of the println(serialized) statement is :
It is strange that printing newObj and innerMap is the same:
As @Varren says, the problem really is in the assert. But:
The assert result:
I am lost! The map must be a Map[Long,Long]!
I must use this version because of Spark dependencies:
- Scala 2.11.11
- jackson-module-scala 2.6.5 and also test with version 2.9.1 with the same result.
Other info: