mirror of
https://github.com/fluencelabs/assemblyscript-json
synced 2025-04-25 06:42:24 +00:00
Add easy serialization to String
This commit is contained in:
parent
2f5e74136e
commit
9b13c7c5ee
@ -16,6 +16,10 @@ export class JSONEncoder {
|
||||
return buffer.subarray(0, buffer.length - 1);
|
||||
}
|
||||
|
||||
toString(): String {
|
||||
return this.result;
|
||||
}
|
||||
|
||||
setString(name: string, value: string): void {
|
||||
this.writeKey(name);
|
||||
this.writeString(value);
|
||||
|
@ -104,7 +104,9 @@ export class StringConversionTests {
|
||||
let resultBuffer = this.handler.serialize();
|
||||
let resultString = String.fromUTF8(resultBuffer.buffer.data, resultBuffer.length);
|
||||
assert(resultString == expectedString,
|
||||
"Expected:\n" + expectedString + "\n" + "Actual:\n" + resultString)
|
||||
"Expected:\n" + expectedString + "\n" + "Actual:\n" + resultString);
|
||||
assert(this.handler.toString() == expectedString,
|
||||
"Expected:\n" + expectedString + "\n" + "Actual:\n" + resultString);
|
||||
return true;
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user