| |
|
|
Michael W. | If one only small Json-Objects/lists of a Programmteil to that others weiterreichen would like, then is Create("Json" really something umständlich.
there would I me the Json.Parse() wish.
It's all right naturally too so
cls /* js& = Json("Parse", jsonstring$) here becomes Create("Json",filename$) uses circa a String one Json-Objekt or a Json-list To transform. The File thereby same again removes. js is the ID the Json-Objektes. whether it worked has: if(js&,"I'm happy","That's ugly") // request works with Json("Parse",s) and with Create("Json",fn$) */ SubProc Json.Parse1 Parameters string jsonstring Declare string s, Dateiname, Content, long js s = Translate$(dt("getDate",5)," ","_") s = Translate$(s,",","_") s = Translate$(s,":","_") s = Translate$(s,"+","p") s = Translate$(s,"-","m") s = Translate$(s,"__","_") MkDir "C:\\Temp" Case %ioresult <> 0 : js = 0 Dateiname = "C:\\Temp\\JSON_" + s + ".json" ' print "File:",Dateiname // File in the temp. directory create Case %ioresult <> 0 : js = 0 Assign #9, Dateiname Case %ioresult <> 0 : js = 0 Rewrite #9 Case %ioresult <> 0 : js = 0 // desired Json-String File write Content = Utf8Encode(jsonstring + "\n") print #9, Content // Case %ioresult <> 0 : js = 0 Close #9 Case %ioresult <> 0 : js = 0 Sleep 100 // Json-Objekt from the String "jsonstring" create js = Create("Json",Dateiname) Case %ioresult <> 0 : fh = 0 Sleep 100 // File again Remove (or to control keep) ' Erase #9 Case %ioresult <> 0 : fh = 0 Return js // The ID the Objektes or. the list give back ENDPROC // Declare long js, cnt, string s
s = "{\qr\q:255, \qg\q:160, \qb\q:80}"
js = Json("Parse1",s) print "js:",js cnt = Json("Count", js) print "count:",cnt print "To parsen:",s print "Result:" WhileLoop 0, cnt - 1 print " ",Json("name", js, &loop),":", Json("Value", js, &loop) EndWhile print "Objekt:",Json("Text",js,0),"\n" waitkey end
small Test angefügt.
this short example goes Yes yet, but something longer is a plainer String rather.
|
|
|
| System: Windows 8/10, XProfan X4 Programmieren, das spannendste Detektivspiel der Welt. | 11/18/20 ▲ |
|
|
|