Skip to content
This repository has been archived by the owner on Jun 7, 2021. It is now read-only.

[TRAFODION-2772] - retrieve a value from Json string got an error #1439

Merged
merged 3 commits into from Feb 7, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 8 additions & 1 deletion core/sql/exp/exp_function.cpp
Expand Up @@ -6503,8 +6503,15 @@ ex_expr::exp_return_type ex_function_json_object_field_text::eval(char *op_data[
Int32 prec2 = ((SimpleType *)getOperand(2))->getPrecision();
len2 = Attributes::trimFillerSpaces( op_data[2], prec2, len2, cs );
}

char *rltStr = NULL;
JsonReturnType ret = json_extract_path_text(&rltStr, op_data[1], 1, op_data[2]);
char jsonStr[len1+1];
char jsonAttr[len2+1];
strncpy(jsonStr, op_data[1], len1);
jsonStr[len1] = '\0';
strncpy(jsonAttr, op_data[2], len2);
jsonAttr[len2] = '\0';
JsonReturnType ret = json_extract_path_text(&rltStr, jsonStr, 1, jsonAttr);
if (ret != JSON_OK)
{
ExRaiseJSONError(heap, diagsArea, ret);
Expand Down