library/src/javascript/JSON/BP-JSON.cc
// attempt to clone json from a path query
attempt to clone json from a path query
attempt to clone json from a path query
P_BP_JSON BP_JSONCloneFromPathQuery
(
	P_BP_JSON  json_to_clone_from,
	char     * lookup_query,
	BP_BOOL    base64_encode_bin_data,
	size_t max_depth_for_token_allocation,
	size_t max_tokens_total
)
{
	if(!json_to_clone_from)
		return NULL;
	if(!lookup_query)
		return NULL;
	if(!BP_JSONCreateOutputFromPathQuery(json_to_clone_from, lookup_query, base64_encode_bin_data))
		return NULL;
	if(!BP_JSONGenerateJSONBufferFromLocalTQ(json_to_clone_from))
		return NULL;
	if(!json_to_clone_from->json_out)
		return NULL;
	P_BP_JSON clone_json = BP_JSONCreateFromBuffer
	(
		json_to_clone_from->json_out,
		bpstrlen(json_to_clone_from->json_out),
		max_depth_for_token_allocation,
		max_tokens_total
	);
	if(!clone_json)
		return NULL;
	if(!clone_json->parse_state)
		return NULL;
	if(json_to_clone_from->json_out)
	{
		ht_free(json_to_clone_from->system_hreg, json_to_clone_from->json_out);
		json_to_clone_from->json_out = NULL;
	}
	return clone_json;
}
P_BP_JSON BP_JSONCloneFromPathQuery ( P_BP_JSON json_to_clone_from , char * lookup_query , BP_BOOL base64_encode_bin_data , size_t max_depth_for_token_allocation , size_t max_tokens_total ) { if ( ! json_to_clone_from ) return NULL ; if ( ! lookup_query ) return NULL ; if ( ! BP_JSONCreateOutputFromPathQuery ( json_to_clone_from , lookup_query , base64_encode_bin_data ) ) return NULL ; if ( ! BP_JSONGenerateJSONBufferFromLocalTQ ( json_to_clone_from ) ) return NULL ; if ( ! json_to_clone_from -> json_out ) return NULL ; P_BP_JSON clone_json = BP_JSONCreateFromBuffer ( json_to_clone_from -> json_out , bpstrlen ( json_to_clone_from -> json_out ) , max_depth_for_token_allocation , max_tokens_total ) ; if ( ! clone_json ) return NULL ; if ( ! clone_json -> parse_state ) return NULL ; if ( json_to_clone_from -> json_out ) { ht_free ( json_to_clone_from -> system_hreg , json_to_clone_from -> json_out ) ; json_to_clone_from -> json_out = NULL ; } return clone_json ; }
attempt to clone json from a path query
attempt to clone json from a path query
// basic null checks // attempt to create output from path query // create json buffer from local TQ (do not use finalize output since we're creating json from a path lookup) // ensure we could create our json // create clone from generated JSON output (reparse) // if we have output set, destroy it before exit // return the cloned json