Aug-24-2020, 08:23 AM
(This post was last modified: Aug-24-2020, 08:24 AM by DreamingInsanity.)
(Aug-24-2020, 08:05 AM)millpond Wrote: I have never seen split used like this. And surprised it works at all.I am parsing the raw data from a string.
Are you parsing the class or the raw data?
I would start with something simple like:
foo=rawdata.split(':')
And join or delete the list slices into appropriate vars.
Here it splits as:
['', '1', '123456', '2', 'name', '42', '3', '30', '4', '', '5', 'somerandomdata', '9', '8']
Time can be assembled as
time = foo[5]+':'+foo[6]+':'+foo[7]+':'+foo[8] for example.
Your method I tried at first (and is what other people seem to). It would work, but there is a floor in that the actual data has about 35 values which would mean you would have
foo[0]
all the way up to foo[35]
and that just makes the code very messy.When I mentioned PHP, here's what I was talking about:
$response = "1:".$result["levelID"].":2:".$result["levelName"].":3:".$desc.":4:".$levelstring.":5:".$result["levelVersion"].":6:".$result["userID"].":8:10:9:".$result["starDifficulty"].":10:".$result["downloads"].":11:1:12:".$result["audioTrack"].":13:".$result["gameVersion"].":14:".$result["likes"].":17:".$result["starDemon"].":43:".$result["starDemonDiff"].":25:".$result["starAuto"].":18:".$result["starStars"].":19:".$result["starFeatured"].":42:".$result["starEpic"].":45:".$result["objects"].":15:".$result["levelLength"].":30:".$result["original"].":31:1:28:".$uploadDate. ":29:".$updateDate. ":35:".$result["songID"].":36:".$result["extraString"].":37:".$result["coins"].":38:".$result["starCoins"].":39:".$result["requestedStars"].":46:1:47:2:48:1:40:".$result["isLDM"].":27:$xorPass"It's just a very long string of data.