How to write code to create points in compute-python?

I was following the method used in here to add curves into the rhino model.

But I’ve just encountered difficulty in creating point objects to the model if I pass through grasshopper definition.

What would be the correct method?
Here is the brief of the code.

#import modules
import compute_rhino3d.Util
import compute_rhino3d.Grasshopper as gh
import rhino3dm
import json

#run compute locally
compute_rhino3d.Util.url = "http://localhost:8081/"
post_url = compute_rhino3d.Util.url + "grasshopper"

#name of files
model = rhino3dm.File3dm()
input_filename = 'simple.ghx'
output_filename = 'simple.3dm'

#modify input values
pt_tr = gh.DataTree("RH_IN:Pt")
n = 2
for i in range(n):
    ptk = rhino3dm.Point3d(i,i,i)
    ptk = json.dumps(ptk.Encode())
    pt_tr.Append([i],[ptk])

trees = [pt_tr]
output = gh.EvaluateDefinition(input_filename, trees)

def ns(name):
    for i in range(len(values)):
        vname = values[i]["ParamName"]
        if (vname == "RH_OUT:" + name):
            return i

tag = "Pt"
dsind = ns(tag)
branch = output['values'][dsind]['InnerTree']['{0}']

item = branch[0]["data"]

json_item = json.loads(item)

#this part would not work???
p = [rhino3dm.CommonObject.Decode(json_item)]

#ideally I should be able to create objects
model.Objects.Add(p[0])

model.Write(output_filename)

here are the files that I used

simple.ghx (119.4 KB)
simple.py (2.9 KB)

I kind of figured out how to do it.
Seems like point object is unique in it’s own or I’m doing something wrong?
Anyway this works…

# name of the files to be used
ghfile = 'point.ghx'
model = rhino3dm.File3dm()
filename = point.3dm'

# combine trees
trees = []

# decode data
output = gh.EvaluateDefinition(ghfile, trees)
values = output['values']

# getting tags, name search
def ns(name):
    for i in range(len(values)):
        vname = values[i]['ParamName']
        if (vname == 'RH_OUT:' + name):
            return i

# search for Data Tree
tag = 'go_pt'
ou_ind = ns(tag)
ou_data = values[ou_ind]['InnerTree']

# retrieve data from given Data Tree
ou_value = list(ou_data.values())
ou_unpack = ou_value[0][0]['data']

# deserialize using json
ds = ou_unpack
ds_js = json.loads(ds)

pt_x = ds_js['X']
pt_y = ds_js['Y']
pt_z = ds_js['Z']

pt_recon = rhino3dm.Point3d(pt_x,pt_y,pt_z)

model.Objects.AddPoint(pt_recon)
model.Write(filename)
``