jsonpath.cpp 785 B

1234567891011121314151617181920212223242526272829303132
  1. #include "jsonpath.h"
  2. #include <yql/essentials/minikql/jsonpath/parser/binary.h>
  3. #include "executor.h"
  4. using namespace NYql;
  5. using namespace NYql::NUdf;
  6. using namespace NJson;
  7. namespace NYql::NJsonPath {
  8. TResult ExecuteJsonPath(
  9. const TJsonPathPtr jsonPath,
  10. const TValue& json,
  11. const TVariablesMap& variables,
  12. const NUdf::IValueBuilder* valueBuilder) {
  13. TExecutor executor(jsonPath, {json}, variables, valueBuilder);
  14. return executor.Execute();
  15. }
  16. TVariablesMap DictToVariables(const NUdf::TUnboxedValue& dict) {
  17. TVariablesMap variables;
  18. TUnboxedValue key;
  19. TUnboxedValue payload;
  20. auto it = dict.GetDictIterator();
  21. while (it.NextPair(key, payload)) {
  22. variables[key.AsStringRef()] = TValue(payload);
  23. }
  24. return variables;
  25. }
  26. }