| 785 } |
785 } |
| 786 |
786 |
| 787 static char* create_linkbutton_jsonvalue(const char *label, const char *uri, gboolean include_null, gboolean visited, gboolean set_visited) { |
787 static char* create_linkbutton_jsonvalue(const char *label, const char *uri, gboolean include_null, gboolean visited, gboolean set_visited) { |
| 788 CxJsonValue *obj = cxJsonCreateObj(NULL); |
788 CxJsonValue *obj = cxJsonCreateObj(NULL); |
| 789 if(label) { |
789 if(label) { |
| 790 cxJsonObjPutString(obj, CX_STR("label"), label); |
790 cxJsonObjPutString(obj, cx_str("label"), label); |
| 791 } else if(include_null) { |
791 } else if(include_null) { |
| 792 cxJsonObjPutLiteral(obj, CX_STR("label"), CX_JSON_NULL); |
792 cxJsonObjPutLiteral(obj, cx_str("label"), CX_JSON_NULL); |
| 793 } |
793 } |
| 794 |
794 |
| 795 if(uri) { |
795 if(uri) { |
| 796 cxJsonObjPutString(obj, CX_STR("uri"), uri); |
796 cxJsonObjPutString(obj, cx_str("uri"), uri); |
| 797 } else if(include_null) { |
797 } else if(include_null) { |
| 798 cxJsonObjPutLiteral(obj, CX_STR("uri"), CX_JSON_NULL); |
798 cxJsonObjPutLiteral(obj, cx_str("uri"), CX_JSON_NULL); |
| 799 } |
799 } |
| 800 |
800 |
| 801 if(set_visited) { |
801 if(set_visited) { |
| 802 cxJsonObjPutLiteral(obj, CX_STR("visited"), visited ? CX_JSON_TRUE : CX_JSON_FALSE); |
802 cxJsonObjPutLiteral(obj, cx_str("visited"), visited ? CX_JSON_TRUE : CX_JSON_FALSE); |
| 803 } |
803 } |
| 804 |
804 |
| 805 CxJsonWriter writer = cxJsonWriterCompact(); |
805 CxJsonWriter writer = cxJsonWriterCompact(); |
| 806 CxBuffer buf; |
806 CxBuffer buf; |
| 807 cxBufferInit(&buf, NULL, 128, NULL, CX_BUFFER_AUTO_EXTEND); |
807 cxBufferInit(&buf, NULL, NULL, 128, CX_BUFFER_AUTO_EXTEND); |
| 808 cxJsonWrite(&buf, obj, (cx_write_func)cxBufferWrite, &writer); |
808 cxJsonWrite(&buf, obj, (cx_write_func)cxBufferWrite, &writer); |
| 809 cxJsonValueFree(obj); |
809 cxJsonValueFree(obj); |
| 810 cxBufferTerminate(&buf); |
810 cxBufferTerminate(&buf); |
| 811 |
811 |
| 812 return buf.space; |
812 return buf.space; |