Sitelet https://web.archive.org/web/20200920182219/https://gitter.im/json-iterator/Lobby
by

Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
  • Sep 19 10:59
    sotex commented #492
  • Sep 18 04:06
    hel2o commented #492
  • Sep 16 04:40
    sotex commented #492
  • Sep 14 12:35
    kamstrup closed #465
  • Sep 14 12:35
    kamstrup commented #465
  • Sep 14 10:42
    qingxp9 opened #495
  • Sep 10 23:42
    manuviswanadhan opened #494
  • Sep 09 14:59
    mhr3 edited #493
  • Sep 09 12:54
    mhr3 opened #493
  • Sep 09 05:42
    hel2o opened #492
  • Sep 04 04:27
    Wisgon closed #491
  • Sep 03 03:07
    Wisgon opened #491
  • Sep 02 08:01
    mythi commented #447
  • Sep 02 05:57
    egonelbre opened #490
  • Sep 02 05:44
    egonelbre opened #5
  • Sep 01 07:33
    Xiaochao8 synchronize #489
  • Sep 01 07:33
    Xiaochao8 opened #489
  • Aug 28 17:35
    x4m commented #488
  • Aug 28 15:59
    isedora commented #488
  • Aug 28 15:21
    x4m opened #488
Laok
@junkao
@taowen Hi, Field (like ID) change to i_d after extra.SetNamingStrategy(LowerCaseWithUnderscores) enable , Is there any way to fixe or enhance
SouthWolf
@southwolf
@taowen Hi, thanks for the great work! But how can I iterate over a jsoniter.arrayAny using Go? Thanks
JohannesM24
@JohannesM24
Hi Guys, just a quick question. When serializing doubles in java why is a double 1.0 not serialized as 1.0 but as 1 in the String? This breaks some of my software when i use type interference. Is there a way to configure jsoniter to do this ?
Andriy Plokhotnyuk
@plokhotnyuk
@JohannesM24 have you called PreciseFloatSupport.enable(); in a static block before parsing?
JohannesM24
@JohannesM24
@plokhotnyuk So easy, thanks a lot :)
Max
@mgtest42
Hi! How to read values from reader instead of bytes? (go)
Here is a small example: https://pastebin.com/mKdqEsvv
If I pass []byte (via BorrowIterator or ResetBytes) - everything is working. But if I use reader - it hangs on WhatIsNext.
Is this a bug? Or I'm doing something wrong?
MarioSilv
@MarioSilv
Hello there :D
I am using JsonIter on a small java project where i found a problem related with enconding.
For example:
I get an response from a rest API (UTF-8), in which, inside exist something like { "name" : "RÉM", "id" : 85 }
If i do JsonIterator.deserialize(String).get("name").toString() the value that i receive its different from original.
But if i use JsonIterator.deserialize(String).toString() the value its equal to original.
Its needed some pre-configuration on JsonIterator?
Thanks in advance.
Regards
Harry Ma
@woshidama323
hi experts .
can i use the jsoniter to parse the data like
{ signedTransaction: '120003240000001268400000000000000C732102C05E14297AF16E26C8B6791C2D3E9B2BAE3BE3B1799C5D19B3A142B8B68FBFB274473045022100E4206AE8294A39E750D7563AA53F4781298887B60735079392F36EAC9E5A516402203EF22B800A17709430F2FFBE7B0AF09C139C506922DBADEE53550453C10AC44C770A726970706C652E636F6D8114AF1E8A7778C7A043C5927AC851F8571CCAC27A0E', id: '4452B677BEA23242B40EB9B317150E74484005F6035AD5238324C9BADD859647' }
?
I have tried to ,but it didn't work
Vliro
@Vliro
Hi! I
Oops. I'm wondering how to perform custom field encoding with Jsoniter, as I need to put directives in the json fields, e.g. if I have the json tag(Golang) "name" I need to encode it as "name@en". Does the API perform such changes, or will I have to fork it? Thanks :)
Leonardo
@lfaoro
guys, using the SetNamingStrategy option doesn't work using the Encoder, I'm using it correctly?
    extra.SetNamingStrategy(extra.LowerCaseWithUnderscores)
    err := jsoniter.NewEncoder(into).Encode(&from)
    if err != nil {
        return errors.Wrap(err, errEncoding)
    }
    return nil
Leonardo
@lfaoro
ok, so is this channel dead?
Andriy Plokhotnyuk
@plokhotnyuk
@lfaoro I can help with Java (https://github.com/json-iterator/java) or Scala (https://github.com/plokhotnyuk/jsoniter-scala) versions only
Leonardo
@lfaoro
@plokhotnyuk the API should be similar, how do you set the naming strategy in java?
Andriy Plokhotnyuk
@plokhotnyuk
APIs are quite different, in Java naming strategies can be set through configs which can be build manually or through Gson/Jackson compatibility mode builders...
In Scala, name mapping is set in compile time only by name mapping function of codec derivation configuration (for snake_case enforcing, etc.) or by @named annotation (usually for exceptional cases)
Dmitry Eliseev
@Madzi
Hi All. Does anybody know how I can use this library with java modular system (jmod + jlink) ?
Or may be I should use some another library ?
ratcash
@ratcashdev
is json-iterator/java#233 expected behavior?
Norvin Burrus
@ndburrus
@Vliro this may be useful: :sparkles:
Norvin Burrus
@ndburrus
@Madzi this may be helpful: :sparkles:
Tervel Atanassov
@tatanassov
Hi, I would like to configure the decoding so if a field is not present the parser doesn't call my setter with a null value. Is that possible?
This is in Java.
Zach McElrath
@zachelrath

@taowen I submitted a PR to add the ability to specify a custom map key sorting function, to allow for, for example, certain map keys to always appear at the top of the serialized map string. Builds are passing, here is the PR and the issue. Thanks!

json-iterator/go#385
json-iterator/go#384

Mathieu Hinderyckx
@mhindery
I'm trying out jsoniter in Go (1.12) and the marshal method seems to be slower than the encoding/json one. Is that a known issue?
Mathieu Hinderyckx
@mhindery

with this as benchmark code

func BenchmarkMarshallStd(b *testing.B) {
    j := CalendarOutput{}
    _ = json.Unmarshal([]byte(outputSmallJsonString), &j)
    b.ResetTimer()
    for i := 0; i < b.N; i++ {
        _, _ = json.Marshal(j)
    }
}

func BenchmarkMarshallIter(b *testing.B) {
    j := CalendarOutput{}
    _ = json.Unmarshal([]byte(outputSmallJsonString), &j)
    b.ResetTimer()
    for i := 0; i < b.N; i++ {
        _, _ = jsoniter.ConfigCompatibleWithStandardLibrary.Marshal(j)
    }
}

I get these results

Mathieus-MacBook-Pro:cmd mhindery$ go test -bench=^BenchmarkMarshall.* -benchmem -cpu 1
goos: darwin
goarch: amd64
pkg: goapi/cmd
BenchmarkMarshallStd     1000000              2408 ns/op             332 B/op          7 allocs/op
BenchmarkMarshallIter    1000000              2669 ns/op             376 B/op          8 allocs/op
PASS
Mathieu Hinderyckx
@mhindery
Only the unmarshall operation seems to be significantly faster
Ryan Boehning
@ryboe
@taowen first, thanks for making this awesome project! it helped me solve a big problem at work
i'm here to ask if you could please retag the v1.1.8 release? it was mistakenly tagged as 1.1.8 (without the v).
json-iterator/go#412
go get github.com/json-iterator/go@v1.1.8 fails
that's it. thanks very much!
Andrey Tararaksin
@atararaksin
Hi! Am I right that if I need to process a large json in a streaming fashion, without loading it into memory, I will have to use Iterator API, and Any API won't do the trick?
Andriy Plokhotnyuk
@plokhotnyuk

@atararaksin Hi, Andrey! If you are asking about Scala reincarnation of jsoniter and your case mentioned in the circe chat then try the following example:

import com.github.plokhotnyuk.jsoniter_scala.macros._
import com.github.plokhotnyuk.jsoniter_scala.core._

import java.io.ByteArrayInputStream

case class Foo(x: Float, y: Float)

val fooCodec: JsonValueCodec[Foo] = JsonCodecMaker.make(CodecMakerConfig)

def customArrayCodec(name: String)(handler: Foo => Unit): JsonValueCodec[Unit] = new JsonValueCodec[Unit] {
  override def decodeValue(in: JsonReader, default: Unit): Unit = {
    if (in.isNextToken('{')) {
      in.skipToKey("foos")
      if (in.isNextToken('[')) {
        do handler(fooCodec.decodeValue(in, fooCodec.nullValue))
        while (in.isNextToken(','))
      }
      if (!in.isNextToken('}')) in.skipToKey("")
    }
  }

  override def encodeValue(x: Unit, out: JsonWriter): Unit = ()

  override val nullValue: Unit = ()
}

val in = new ByteArrayInputStream("""{"name":"test","foos":[{"x":1.0,"y":2.0},{"x":3.0,"y":4.0}],"bars":[]}""".getBytes("UTF-8"))
readFromStream[Unit](in)(customArrayCodec("test") { foo =>
  println(foo)
})

It should print:

Foo(1.0,2.0)
Foo(3.0,4.0)
Andrey Tararaksin
@atararaksin
@plokhotnyuk Thank you, this looks promising; I will see if it works for me tomorrow
Andriy Plokhotnyuk
@plokhotnyuk
Great! Please take in account that instead of ByteArrayInputStream you can use any InputStream
Also, possible, you would be interested to look into those projects too: https://github.com/plokhotnyuk/rtree2d and https://github.com/Leaflet/Leaflet
Andrey Tararaksin
@atararaksin
@plokhotnyuk Thanks again, this totally worked
Nikolay Dubina
@nikolaydubina
Hello guys, please review this bugfix json-iterator/go#480. Thanks!
Gavin Bisesi
@Daenyth

:wave: Is jsoniter able to lazily dig into / stream from a large json file, the values from inside a json array which is inside an object?

Example

{"data": [1, 2, 3, 4, ...] }

^ I'd like to stream 1, 2, 3, 4 etc with fixed memory overhead

I know the library supports lazy streaming, but I don't see an example jumping out from the docs on how to do it when lensing into a structure
Andriy Plokhotnyuk
@plokhotnyuk
Hi, Gavin! Which version do you mean Go, Java or Scala?
Gavin Bisesi
@Daenyth

Scala but I can use the java interface if need be.

I'll be integrating with fs2 ultimately, but I can do that via the callback style interface. I have an old gist to that effect

( https://gist.github.com/Daenyth/a3190525c7163a8724d79c486dc46479 unless the api has changed since ~17mo ago)
Andriy Plokhotnyuk
@plokhotnyuk
Great! Welcome to the jsoniter-scala chat to do not spam here: https://gitter.im/plokhotnyuk/jsoniter-scala
Gavin Bisesi
@Daenyth
kk