Thursday, April 26, 2012
Notes on Gson (when converting a Json string to a Java Object)
Google's Gson library provides a handy way to convert Java Class from/to Json strings using fromJson() and toJson() function.
When converting a Json string to Java object, it is important that the fields' names in the Java Class must be exactly the same as the keys' names in the Json String. The visibility of the fields' name does not matter. E.g.:
String json = "{'key1':'1', 'key2':2}";
class Object {
public String key1;
private int key2;
}
Object objs = new Gson().fromJson(json, Object.class);
Otherwise, the null values will returned for each field.
Tuesday, April 17, 2012
Identify Functions Definition within a C Source File
1. Use the ctags tools, on a console, typing in "ctags -x --c-kinds=f " with the file name(s) (e.g. "flex.c"):
ctags -x --c-kinds=f flex.c
will generate the list of C functions defined in "flex.c" file:
FlexParser function 2228 flex.c extern parserDefinition* FlexParser (void)
addContext function 786 flex.c static void addContext (tokenInfo* const parent, const tokenInfo* const child)
addToScope function 796 flex.c static void addToScope (tokenInfo* const token, vString* const extra)
buildFlexKeywordHash function 207 flex.c static void buildFlexKeywordHash (void)
copyToken function 705 flex.c static void copyToken (tokenInfo *const dest, tokenInfo *const src)
...
Ref.: http://ctags.sourceforge.net/ctags.html
ctags -x --c-kinds=f flex.c
will generate the list of C functions defined in "flex.c" file:
FlexParser function 2228 flex.c extern parserDefinition* FlexParser (void)
addContext function 786 flex.c static void addContext (tokenInfo* const parent, const tokenInfo* const child)
addToScope function 796 flex.c static void addToScope (tokenInfo* const token, vString* const extra)
buildFlexKeywordHash function 207 flex.c static void buildFlexKeywordHash (void)
copyToken function 705 flex.c static void copyToken (tokenInfo *const dest, tokenInfo *const src)
...
Ref.: http://ctags.sourceforge.net/ctags.html
Subscribe to:
Posts (Atom)