Skip to content

Instantly share code, notes, and snippets.

@mppf
Created August 10, 2017 14:52
Show Gist options
  • Save mppf/89fe1274da543b580a4e1f85e3fa6c1d to your computer and use it in GitHub Desktop.
Save mppf/89fe1274da543b580a4e1f85e3fa6c1d to your computer and use it in GitHub Desktop.
Example of reading JSON with a Chapel class
class Fighter {
var subclass:string;
var level:int;
}
var mem = openmem();
var writer = mem.writer().write('{"subclass":"ninja", "level":3}');
var reader = mem.reader();
// This works
//var f = new Fighter();
//reader.readf("%jt", f);
// This doesn't
var f:Fighter;
reader.readf("%jt", f);
writeln(f);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment