V: Playground example is not working

Created on 26 May 2020  路  6Comments  路  Source: vlang/v

I believe it was reported earlier as well (See #4273 and #4757 etc) but playground example for json encoding/decoding is not working again.

Steps to reproduce:

Bug Playground

All 6 comments

@Sparkenstein try paste the example to https://devbits.app/play

@nedpals wdym? https://devbits.app/play is Go playground not V

@Mikilis there's an option to switch to V as well.

Sample code to reproduce the issue:

import json

struct User {
    name string
}

data := '{ "name": "Bob" }'

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

println(user.name)

Error displayed:

/vlib/json/json_primitives.v:8:3: error: To use @VROOT, you need to have a "v.mod" file in /vlib/json, or in one of its parent folders. 
    6 | #flag -I @VROOT/thirdparty/cJSON
    7 | #flag @VROOT/thirdparty/cJSON/cJSON.o
    8 | #include "cJSON.h"
      |   ~~~~~~~~~~~~~~~~
    9 | #define js_get(object, key) cJSON_GetObjectItemCaseSensitive((object), (key))
   10 | struct C.cJSON {

Can confirm the sample runs without errors on https://devbits.app/play.

Looks like duplicate of #3327 as well as #4892 - probably some of these could be closed.

Closing this as the old playground has been retired.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

markgraydev picture markgraydev  路  3Comments

radare picture radare  路  3Comments

lobotony picture lobotony  路  3Comments

elimisteve picture elimisteve  路  3Comments

jtkirkpatrick picture jtkirkpatrick  路  3Comments