Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
  • Apr 17 06:29
    johnsonjh closed #535
  • Apr 13 16:37
    282857484 edited #544
  • Apr 13 16:36
    282857484 closed #544
  • Apr 13 16:36
    282857484 commented #544
  • Apr 13 16:12
    282857484 edited #544
  • Apr 13 16:11
    282857484 opened #544
  • Apr 08 14:35
    jsl422 opened #543
  • Apr 02 06:13
    AsterDY edited #531
  • Apr 02 06:13
    AsterDY edited #531
  • Apr 01 10:57
    matoous opened #542
  • Mar 31 08:22
    Dwyane-Xu opened #541
  • Mar 29 16:49
    WillAbides opened #540
  • Mar 28 23:29
    WillAbides commented #519
  • Mar 25 13:48
    luigi-asprino opened #296
  • Mar 22 12:05
    Valdenirmezadri commented #470
  • Mar 20 16:24
    advancedwebdeveloper opened #539
  • Mar 18 09:17
    panol commented #399
  • Mar 17 09:08
    nurlybekovnt opened #538
  • Mar 14 20:53
    nurlybekovnt opened #537
  • Mar 12 12:01
    wuhan005 edited #536
Harry Ma
@woshidama323
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?
Shankar Parimi
@ShankarParimi
does json-iter/go support custom field mapping? are there any examples for such?
Иван Сердюк
@oceanfish81_twitter
Anyone interested to build this project with https://github.com/bazelbuild/rules_go ?
One Thawt
@onethawt
Hey guys, bit of a java newbie, but boss gave me some code to modify. I'm using JsonStream.serialize on a POJO with a LocalDateTime. Is there an annotation I can use to specify the formatting?
One Thawt
@onethawt
got it figured out, registered a type Encoder. thanks!
Иван Сердюк
@oceanfish81_twitter