ejGetParam | GoAhead JavaScript API | GoAhead EMF |
Retrieve a value from a JavaScript encoded string.
#include "ej.h" char_t *ejGetParam(char_t *paramList, char_t *key);
paramList | JavaScript formatted parameter list |
key | Name of the key to look up within paramString |
ejGetParam is a utility function to allow for easy extraction of values from a string of key/value pairs in JavaScript format. The caller is responsible for freeing memory allocated by this function for the return value.
The JavaScript format is as follows:
var1="5";var2="another value";var3="yet another value";
Returns the value associated with the given key within the parameter list. If the key is not found or paramList cannot be successfully parsed, NULL is returned.
Note: This function allocates memory for the return value. This memory must be explicitly freed using bfree or bfreeSafe.
char_t *day, *month, *year; char_t param = "month=\"5\";day=\"15\";year=\"1999\";"; day = ejGetParam(param, "day"); month = ejGetParam(param, "month"); year = ejGetParam(param, "year"); if (day && month && year) { printf("%s/%s/%s\n", month, day, year); 5/15/1999 } bfreeSafe(B_L, day); bfreeSafe(B_L, month); bfreeSafe(B_L, year);