V: json module still has a bug

Created on 22 Jun 2019  路  5Comments  路  Source: vlang/v

this code will raise "You just found a bug. V can't compile this program, but it should. Please create a GitHub issue."

import json

println('ok')

the code from the example doesn't work:

import json

struct User {
    name string
    age  int
}

data := '{ "name": "Frodo", "age": 25 }'

user := json.decode(User, data) or {
    eprintln('Failed to decode json')
    return
}
println(user.name)
println(user.age)

looks like str() has been removed?

All 5 comments

@bitsnaps
I think duplicated with https://github.com/vlang/v/issues/361

@musou1500 still raise the same msg fatal error: 'json/cJSON/cJSON.c' file not found, looks like it still depends on cJSON

@bitsnaps Yes. json module depends on cJSON.
currently, you need to put cJSON library to the proper place.

of course, I think it should be fixed.
It seems there is a plan to remove cJSON dependency.
https://github.com/vlang/v/blob/b1553449d8e17f10560db3e39eec1c5278fe3eea/compiler/jsgen.v#L7

I created a PR. it will resolves this issue.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

lobotony picture lobotony  路  3Comments

oleg-kachan picture oleg-kachan  路  3Comments

elimisteve picture elimisteve  路  3Comments

XVilka picture XVilka  路  3Comments

shouji-kazuo picture shouji-kazuo  路  3Comments