Skip to content

Instantly share code, notes, and snippets.

@MadcapJake
Last active May 29, 2017 22:12
Show Gist options
  • Save MadcapJake/90275f529ce88c0895a1d1a282cc9a35 to your computer and use it in GitHub Desktop.
Save MadcapJake/90275f529ce88c0895a1d1a282cc9a35 to your computer and use it in GitHub Desktop.
JSON pointer setting
struct json_object* jobj = json_object_new_object();

ctr_internal_object_set_property(
	jsonObjectInstance,
	ctr_build_string_from_cstring( "_pointer" ),
	ctr_build_number_from_float((long) jobj),
	CTR_CATEGORY_PRIVATE_PROPERTY
);
/**
 * @internal
 *
 * Converts ctr_object pointer to a json pointer
 **/
struct json_object* ctr_json_internal_jsonptr(ctr_object* co) {
	return (struct json_object*) (long) co->value.nvalue;
}
ctr_object* jobjPtrProp;

jobjPtrProp = ctr_internal_object_find_property(
	myself,
	ctr_build_string_from_cstring( "_pointer" ),
	CTR_CATEGORY_PRIVATE_PROPERTY
);

json_object_object_add(ctr_json_internal_jsonptr(jobjPtrProp),
		       (const char*) key,
		       json_object_new_string((const char*) val)
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment