View Single Post
Nikkii
Member
Join Date: Feb 2012
Old 03-18-2013 , 01:39   Re: [INC] JSON in pure SP - Port from AMXX pawn
Reply With Quote #10

A little treat for everyone, now with working decoding

https://raw.github.com/nikkiii/logup...clude/json.inc (Previous paste.ee link had a bug with string lengths, this implementation will be fixed a lot more often if broken)

Testing:
http://paste.ee/r/yqhgL

Results:
Code:
L 03/18/2013 - 01:38:30: [testjson.smx] Trying to decode: {"integer": 1, "string": "Hello World", "integer2": 2}
L 03/18/2013 - 01:38:30: [testjson.smx] --> Passed
L 03/18/2013 - 01:38:30: [testjson.smx] Trying to decode: {"string": "Hello World"}
L 03/18/2013 - 01:38:30: [testjson.smx] --> Passed
L 03/18/2013 - 01:38:30: [testjson.smx] Trying to decode: {"bool": true}
L 03/18/2013 - 01:38:30: [testjson.smx] --> Passed
L 03/18/2013 - 01:38:30: [testjson.smx] Trying to decode: {"null": null}
L 03/18/2013 - 01:38:30: [testjson.smx] --> Failed
L 03/18/2013 - 01:38:30: [testjson.smx] Running self tests on data...
L 03/18/2013 - 01:38:30: [testjson.smx] --> String: Passed
L 03/18/2013 - 01:38:30: [testjson.smx] --> Boolean: Passed
L 03/18/2013 - 01:38:30: [testjson.smx] --> Integer: Passed
L 03/18/2013 - 01:38:30: [testjson.smx] --> Data tests Passed
'null' was not implemented in the original parser, so I didn't change a thing about that. The important part is that it decodes at least basic JSON just fine.
__________________
Owner of ProbablyAServer, a server without game changing mods and donation benefits

RCON Helper | [TF2] LogUpload | CCC Donator Tags | PHP Steam API Wrapper

Last edited by Nikkii; 06-08-2013 at 08:12.
Nikkii is offline