Add a value to knowledge graph by giving a jsonpath

        Args:
            field_name: str
            jsonpath: str

        Returns:
175932
def _add_doc_value(self, field_name: str, jsonpath: str) -> None:
        
        path = self.origin_doc.etk.parse_json_path(jsonpath)
        matches = path.find(self.origin_doc.value)
        all_valid = True
        invalid = []
        for a_match in matches:
            # If the value is the empty string, we treat is a None.
            if a_match.value:
                valid = self._add_value(field_name, a_match.value, provenance_path=str(a_match.full_path))
                if not valid:
                    invalid.append(field_name + ":" + str(a_match.value))
                all_valid = all_valid and valid

        if not all_valid:
            raise KgValueError("Some kg value type invalid according to schema: " + json.dumps(invalid))
607951
def add(self, field, op=None, val=None):
        
        if field.has_subfield():
            self._fields[field.full_name] = 1
        else:
            self._fields[field.name] = 1
        if op and op.is_size() and not op.is_variable():
            # get minimal part of array with slicing,
            # but cannot use slice with variables
            self._slices[field.name] = val + 1
        if op and op.is_variable():
            # add the variable too
            self._fields[val] = 1
42406
def get_value(self, field_name):
        
        if field_name in self.fields:
            return self._dict['attributes'][field_name]
        elif field_name.upper() in ['SHAPE', 'SHAPE@', "GEOMETRY"]:
            return self._dict['geometry']
        return None
874515
def jsontype(self, name, path=Path.rootPath()):
        
        return self.execute_command('JSON.TYPE', name, str_path(path))
748548
def field_value(ast, field_name)
      field(ast, field_name).xpath('.//args_add_block//tstring_content
        [count(ancestor::args_add) = 1][count(ancestor::string_add) = 1]
        /@value').map { |a| a.to_s }.last
    end
288832
def get_json_path(self, path):
        
        return self.with_json_path(path, field='result').values_list('result', flat=True)
158923
def jsonobjlen(self, name, path=Path.rootPath()):
        
        return self.execute_command('JSON.OBJLEN', name, str_path(path))
784415
def get_dict_for_field(self, field_name):
        
        try:
            field = self.model._meta.get_field(field_name)
        except FieldDoesNotExist:
            field = None
        return {
            'label': self.get_field_label(field_name, field),
            'value': self.get_field_display_value(field_name, field),
        }
974909
def addfield(self, pkt, s, val):
        """"""
        tmp_len = self.length_of(pkt)
        if tmp_len == 0:
            return s
        internal = self.i2m(pkt, val)[-tmp_len:]
        return s + struct.pack("!%ds" % tmp_len, internal)
562676
def add_composite_field(self, name, field):
        
        self.composite_fields[name] = field
        self._init_composite_field(name, field)
1210419
def jsonarrlen(self, name, path=Path.rootPath()):
        
        return self.execute_command('JSON.ARRLEN', name, str_path(path))
588797
def import_schema_to_json(name, store_it=False):
    

    schema_file = u"%s.json" % name
    file_path = os.path.join(SCHEMA_ROOT, schema_file)
    log.debug(u"trying to load %s " % file_path)
    schema = None
    try:
        schema_file = open(file_path, "r").read()
    except IOError, e:
        log.error(u"file not found %s" % e)
        msg = "Could not find schema file. %s" % file_path
        raise SalesKingException("SCHEMA_NOT_FOUND", msg)
    schema = json.loads(schema_file)

    if schema is None:
        msg = "loading failed foo %s" % name
        raise SalesKingException("SCHEMA_NOT_FOUND", msg)
    return schema
1031008
public static String buildPath(JsonPath jsonPath) {
        List<String> urlParts = new LinkedList<>();

        JsonPath currentJsonPath = jsonPath;
        String pathPart;
        do {
            if (currentJsonPath instanceof RelationshipsPath) {
                pathPart = RELATIONSHIP_MARK + SEPARATOR + currentJsonPath.getElementName();
            } else if (currentJsonPath instanceof FieldPath) {
                pathPart = currentJsonPath.getElementName();
            } else {
                pathPart = currentJsonPath.getElementName();
                if (currentJsonPath.getIds() != null) {
                    pathPart += SEPARATOR + mergeIds(currentJsonPath.getIds());
                }
            }
            urlParts.add(pathPart);

            currentJsonPath = currentJsonPath.getParentResource();
        } while (currentJsonPath != null);
        Collections.reverse(urlParts);

        return SEPARATOR + StringUtils.join(SEPARATOR, urlParts) + SEPARATOR;
    }
509796
def set_value(self, field_name, value):
        
        if field_name in self.fields:
            if not value is None:
                self._dict['attributes'][field_name] = _unicode_convert(value)
            else:
                pass
        elif field_name.upper() in ['SHAPE', 'SHAPE@', "GEOMETRY"]:
            if isinstance(value, dict):
                if 'geometry' in value:
                    self._dict['geometry'] = value['geometry']
                elif any(k in value.keys() for k in ['x','y','points','paths','rings', 'spatialReference']):
                    self._dict['geometry'] = value
            elif isinstance(value, AbstractGeometry):
                self._dict['geometry'] = value.asDictionary
            elif arcpyFound:
                if isinstance(value, arcpy.Geometry) and \
                   value.type == self.geometryType:
                    self._dict['geometry']=json.loads(value.JSON)
            self._geom = None
            self._geom = self.geometry
        else:
            return False
        self._json = json.dumps(self._dict, default=_date_handler)
        return True
1076360
def jsonarrappend(self, name, path=Path.rootPath(), *args):
        
        pieces = [name, str_path(path)]
        for o in args:
            pieces.append(self._encode(o))
        return self.execute_command('JSON.ARRAPPEND', *pieces)
1236164
def add_field(self, name, default=None, required=False, error=None):
        
        if name is None:
            return
        self.field_arguments.append(dict(
            name=name,
            default=default,
            required=required,
            error=error))
690590
public Expression add(String field, JsonNode value) {
        try {
            ((ObjectNode) node).set(field, value);
            return this;
        } catch (ClassCastException e) {
            throw new RuntimeException("Object node expected while adding " + field);
        }
    }