Re: Passing Map to Remote App
- Posted by irv Mar 12, 2019
- 1227 views
You can probably use save_map() and load_map():
map a = map:new_from_kvpairs({ {"name","Jerry Smith"}, {"age",`16`}, -- note, numbers must be quoted somehow; {"bal",`49.95`}, {"city","Buffalo NY"}, {"phone","000-555-1212"}, {"pix","thumbnails/Jerry.jpg"}}) save_map(a,canonical_path("~/demos/resources/Jerry.map"),SM_RAW)
If you use SM_RAW mode, the output will be like this:
þþ;9:B9<:;:B9B=Bþ:=7:79)mnnuxyvnw})1>A?:C>@:@B:@:mknm5);9:>69;69;):=C:AC><2þþwjvnþjpnþyrþkjuþyqxwnþlr}þþSn{{)\vr}qþ:?þ}q~vkwjru|8Sn{{7sypþ=B7B>þ9996>>>6:;:;þ K~oojux)WbThere are lots of non-readable characters in there: ETX,ACK,EOT,VT, etc.
If you use SM_TEXT, then the results are human-readable:
\#22name\#22 = \#22Jerry Smith\#22 \#22age\#22 = \#2216\#22 \#22pix\#22 = \#22thumbnails/Jerry.jpg\#22 \#22bal\#22 = \#2249.95\#22 \#22phone\#22 = \#22000\-555\-1212\#22 \#22city\#22 = \#22Buffalo NY\#22
Either way:
object x = load_map("resources/Jerry.map") display(map:get(x,"name")) -- displays Jerry Smith
Which mode may be easier/safer to transfer is left up to your experimentation. The raw mode map may need to be encoded in order to transfer it. What transport protocol do you intend to use?