Jump to content


Martin2789's Content

There have been 5 items by Martin2789 (Search limited from 19-September 20)


By content type

See this member's

Sort by                Order  

#164883 var name building from string data

Posted by Martin2789 on 14 February 2014 - 03:48 PM in Ask a Pro

Thank you very much works like a charm ;)



#164862 var name building from string data

Posted by Martin2789 on 14 February 2014 - 02:04 PM in Ask a Pro

i found this but i dont understand it how to use it i want to write a little program to fill the screens at spawn for this i want to use JSON which looks something like this:
{"monitornorth": [{
			"firstline": "John",
			"secline": "Doe",
			"txtcol": "colors.white",
			"backcol": "colors.blue"
}]}
Thanks to LBPHacker and this JSON-API i am able to read this data from the server with
print(obj.monitornorth[1].firstline)
I dont want to modify every pc but i will label them is it possible to String concatenate a variable name?
sth. like this?

var varstring = "obj."..os.getComputerLabel().."[1].firstline"
local var = getfenv()[varstring]
But i thinks thats only the "name" of the variable am i right?
Thank you for your time

TL TR: variable build via generated string(os.getComputerLabel())



#164841 JSON API usage

Posted by Martin2789 on 14 February 2014 - 11:18 AM in Ask a Pro

View PostLBPHacker, on 13 February 2014 - 12:51 PM, said:

Take a look at that piece of JSON again. monitornorth is an array with one object in it. That object is the first thing in monitornorth, so this is how you access it:
print(obj.monitornorth[1].firstline)

Thank you very much... now it is clear why it didn't worked Thank you very very much!!!



#164643 JSON API usage

Posted by Martin2789 on 12 February 2014 - 02:30 PM in Ask a Pro

Repost from the JSON-Api Thread. I would like to read a JSON File which has more layers :

View PostMartin2789, on 11 February 2014 - 03:37 PM, said:

Nice Api you have there i get it to work with easy json like:
		{
			"firstline": "John",
			"secline": "Doe",
			"txtcol": "colors.white",
			"backcol": "colors.blue"
		}
with
os.loadAPI("json")
str = http.get("http://www.someserver.com/").readAll()
obj = json.decode(str)
print(obj.firstline)
but with complicated json like:

{
	"monitornorth": [
		{
			"firstline": "John",
			"secline": "Doe",
			"txtcol": "colors.white",
			"backcol": "colors.blue"
		}
	]
}

os.loadAPI("json")
str = http.get("http://www.someserver.com/").readAll()
obj = json.decode(str)
print(obj.monitornorth.firstline)
obj.monitornorth.firstline is empty
What do i do wrong?



#164510 JSON API v2.0.1 for ComputerCraft

Posted by Martin2789 on 11 February 2014 - 03:37 PM in APIs and Utilities

Nice Api you have there i get it to work with easy json like:
		{
			"firstline": "John",
			"secline": "Doe",
			"txtcol": "colors.white",
			"backcol": "colors.blue"
		}
with
os.loadAPI("json")
str = http.get("http://www.someserver.com/").readAll()
obj = json.decode(str)
print(obj.firstline)
but with complicated json like:

{
	"monitornorth": [
		{
			"firstline": "John",
			"secline": "Doe",
			"txtcol": "colors.white",
			"backcol": "colors.blue"
		}
	]
}

os.loadAPI("json")
str = http.get("http://www.someserver.com/").readAll()
obj = json.decode(str)
print(obj.monitornorth.firstline)
What am i do wrong?
EDIT:

View PostLBPHacker, on 13 February 2014 - 12:51 PM, said:

Take a look at that piece of JSON again. monitornorth is an array with one object in it. That object is the first thing in monitornorth, so this is how you access it:
print(obj.monitornorth[1].firstline)
Thank you LBPHacker ;)