Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
  • Dec 09 20:08
    skjolber opened #257
  • Dec 03 20:04
    codecov[bot] commented #424
  • Dec 03 20:01
    aaronbee opened #424
  • Dec 01 12:07
    zwl1619 closed #333
  • Nov 29 08:04
    ivila commented #333
  • Nov 29 04:27
    ivila commented #333
  • Nov 28 19:17
    willtemperley opened #256
  • Nov 28 15:01
    codecov[bot] commented #423
  • Nov 28 14:58
    codecov[bot] commented #423
  • Nov 28 14:56
    vano144 opened #423
  • Nov 22 16:04
    codecov[bot] commented #422
  • Nov 22 16:02
    codecov[bot] commented #422
  • Nov 22 16:01
    JensErat edited #422
  • Nov 22 16:00
    JensErat commented #422
  • Nov 22 15:59
    JensErat opened #422
  • Nov 22 15:20
    disq opened #421
  • Nov 20 09:38
    rwelin commented #420
  • Nov 20 09:36
    codecov[bot] commented #420
  • Nov 20 09:34
    codecov[bot] commented #420
  • Nov 20 09:34
    codecov[bot] commented #420
Brian Brazil
@brian-brazil
There also doesn't seem to be a way to write strings/bytes without involving an alloc
Brian Brazil
@brian-brazil
json-iterator/go#234 should fix the allocs
Sara Ervik
@saraervik
Hi! I am a student in a group project where the assignment is to work with open source :smile: I am working with extending the coverage and adding tests, but I find it difficult. Could you provide some help?
Andriy Plokhotnyuk
@plokhotnyuk
Hi Sara! It is a really hard assignment, you have to reverse engineer requirements from the code and translate them to tests... but usually creating of tests should guide a design of the code: http://www.growing-object-oriented-software.com/
Sara Ervik
@saraervik
Thank you for your answer @plokhotnyuk , when looking at the exisiting tests, it seems to be very few unit tests and more full system testing. Is it deliberately designed this way?
Andriy Plokhotnyuk
@plokhotnyuk
For small projects (like here https://github.com/plokhotnyuk/calculator ) end to end tests can check all requirements, but when the system grows to layers of subsystems unit tests will help a lot.
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!