|
Just modify the code from
module('json.rpc')
local json = require('json') local http = require("socket.http") to
local json = require('json')
local http = require("socket.http") module('json.rpc') 2010-11-10
发件人: sagasw <sagasw@gmail.com>
发送时间: 2010-11-10 08:44
主 题: a naive issue about json4lua
收件人: lua-l@lists.lua.org
When I try to use the json4lua, encounter a naive issue that make trouble for me. I download the json4lua 0.9.30 from http://json.luaforge.net/ indeed the latest version is 0.9.50, but I don't think it is the point. I just use lua for windows, and place the folder json under e:\Lua\5.1\lua\. So under folder E:\Lua\5.1\lua\json, I could see 3 lua files "json.lua rpc.lua rpcserver.lua" some testing code like: ---------------------------------------- json = require("json") testString = [[ { "one":1 , "two":2, "primes":[2,3,5,7] } ]] o = json.decode(testString) table.foreach(o,print) print ("Primes are:") table.foreach(o.primes,print) require ("json.rpc") result, error = json.rpc.call("http://jsolait.net/testj.py","echo","Test echo!") print(result) ---------------------------------------- and the result like: ---------------------------------------- one 1 primes table: 00630588 two 2 Primes are: 1 2 2 3 3 5 4 7 lua: E:\lua\5.1\lua\json\rpc.lua:30: attempt to call global 'require' (a nil value) stack traceback: E:\lua\5.1\lua\json\rpc.lua:30: in main chunk [C]: in function 'require' first.lua:8: in main chunk [C]: ? >Exit code: 1 You could see the test for json returns correct result. But failed to call rpc.lua, the rpc.lua looks like following, and failed part is the line "require('json')": module('json.rpc') local json = require('json') local http = require("socket.http") Could anyone tell me how to fix the issue? What should I do or make some setting change? thanks, ------------------------------------------ blog: http://sunxiunan.com/ C++, Lua, living in Dalian http://twitter.com/sagasw ------------------------------------------ |