Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
  • Nov 25 07:23
    chrisyip edited #515
  • Nov 25 07:21
    chrisyip opened #515
  • Nov 19 14:06
    gmokki commented #245
  • Nov 19 00:33
    calbot closed #514
  • Nov 19 00:33
    calbot commented #514
  • Nov 19 00:09
    calbot commented #514
  • Nov 18 23:33
    calbot opened #514
  • Nov 18 19:57
    catenacyber commented #510
  • Nov 18 01:32

    AllenX2018 on master

    fix issue 510 Merge pull request #513 from Al… (compare)

  • Nov 18 01:32
    AllenX2018 closed #513
  • Nov 18 01:31
    AllenX2018 closed #510
  • Nov 17 09:43
    AllenX2018 edited #513
  • Nov 17 09:42
    AllenX2018 opened #513
  • Nov 16 13:41
    mferretti commented #225
  • Nov 16 13:41
    mferretti commented #225
  • Nov 16 13:16
    ingomueller-net commented #225
  • Nov 16 06:44
    AllenX2018 commented #510
  • Nov 16 06:44
    AllenX2018 commented #510
  • Nov 16 03:53
    AllenX2018 labeled #510
  • Nov 16 03:53
    AllenX2018 assigned #510
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
Иван Сердюк
@oceanfish81_twitter
Hi. Could someone explain: why this project relies on https://github.com/modern-go/reflect2 ?
hzjmobile
@hzjmobile
hi!How to add JSON-Iterator to Spring WebFlux?
Dieter Plaetinck
@Dieterbe
hi, i'm reading a huge streaming input using an iterator. is it possible to , while i'm iterating and worknig through the stream, to decode certain smaller substructures using Unmarshal() or similar?