Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
  • Apr 03 09:52
    AllenX2018 commented #452
  • Apr 03 09:31
    magicnana999 opened #452
  • Apr 03 09:24
    magicnana999 closed #451
  • Apr 03 09:23
    magicnana999 opened #451
  • Apr 01 09:08
    zspitzer opened #264
  • Mar 30 08:43

    AllenX2018 on master

    temporarily comment out some te… (compare)

  • Mar 30 08:26

    AllenX2018 on master

    fix issue #421 add more testcase Merge pull request #433 from Al… (compare)

  • Mar 30 08:26
    AllenX2018 closed #433
  • Mar 28 09:49
    AllenX2018 commented #448
  • Mar 28 01:49
    fangguangyang commented #449
  • Mar 27 08:36
    duguying commented #448
  • Mar 27 08:35
    duguying commented #448
  • Mar 27 08:35
    duguying commented #448
  • Mar 26 11:38
    AllenX2018 commented #449
  • Mar 26 11:37
    AllenX2018 commented #450
  • Mar 26 11:37

    AllenX2018 on master

    fix any str ToInt64 ToUint64 pa… Merge pull request #450 from fa… (compare)

  • Mar 26 11:37
    AllenX2018 closed #450
  • Mar 26 11:28
    AllenX2018 review_requested #447
  • Mar 26 10:26
    fantastao commented #450
  • Mar 26 10:25
    fantastao commented #450
Tao Wen
@taowen
@saraervik it is pretty important to explore the test space by generating random data. There is https://github.com/google/gofuzz that can generate data. But there are two missing requirements: 1. generate data for interface{} or any interface. 2. generate the type structure randomly. For simple library like json parser, there are limited interaction combinations, most of the time it is just marshal => unmarshal. So random data is sufficient to test it. For more complex library, there are lots of api, lots of interaction sequence, randomize the action list itself is worth considering.
Niranjan
@nnanda2016
@taowen Why parsing of an invalid Json string does not throw an exception? Like I tried parsing {\"name\": \"taowen\" \"tags\": [\"crazy\", \"hacker\"]} as final JsonIterator anyObj = JsonIterator.parse(baseJson);, but it didn't throw any exception.
Tao Wen
@taowen
parse is done lazily. You need to read value to trigger the reading
Vadim Raksha
@hasdfa
@taowen Is it secure? Can I use it in enterprise project? I don`t sure about that. Some developers from my team told that it can exist be some kind of backdoor in this library (for golang).
Tao Wen
@taowen
@hasdfa it is open source project. you can audit it yourself, or pay 3rd party to do code auditing.
Yuri Pereira Constante
@ypconstante
Hi, there is some way to know if the number in the Any class is a long or a double? In jackson there is a separated JsonToken for int and float type, but in jsoniter there is just number in ValueType
Tao Wen
@taowen
the number has not been read yet, so Any does not know it is long or double
charles.chen
@woraser
@taowen Hi,I have a problem, why use copy(copied, result) after get result ?why not return result directly?
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
@y0ssar1an
@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