| 1940 | |
| 1941 | |
| 1942 | int json_get_path_next(json_engine_t *je, json_path_t *p) |
| 1943 | { |
| 1944 | json_path_step_t *last_step= |
| 1945 | (p->last_step_idx < 0) ? |
| 1946 | ((json_path_step_t*) |
| 1947 | (p->steps.buffer)-1): |
| 1948 | ((json_path_step_t*) |
| 1949 | (p->steps.buffer) + (p->last_step_idx)), |
| 1950 | *initial_step= (json_path_step_t*) (p->steps.buffer); |
| 1951 | if (last_step < initial_step) |
| 1952 | { |
| 1953 | if (json_read_value(je)) |
| 1954 | return 1; |
| 1955 | |
| 1956 | p->last_step_idx= 0; |
| 1957 | initial_step->type= JSON_PATH_ARRAY_WILD; |
| 1958 | initial_step->n_item= 0; |
| 1959 | return 0; |
| 1960 | } |
| 1961 | else |
| 1962 | { |
| 1963 | last_step= (json_path_step_t*)(p->steps.buffer) + p->last_step_idx; |
| 1964 | if (json_value_scalar(je)) |
| 1965 | { |
| 1966 | if (last_step->type & JSON_PATH_ARRAY) |
| 1967 | last_step->n_item++; |
| 1968 | } |
| 1969 | else |
| 1970 | { |
| 1971 | p->last_step_idx++; |
| 1972 | get_json_step(p, last_step); |
| 1973 | last_step->type= (enum json_path_step_types) je->value_type; |
| 1974 | last_step->n_item= 0; |
| 1975 | } |
| 1976 | |
| 1977 | if (json_scan_next(je)) |
| 1978 | return 1; |
| 1979 | } |
| 1980 | |
| 1981 | do |
| 1982 | { |
| 1983 | switch (je->state) |
| 1984 | { |
| 1985 | case JST_KEY: |
| 1986 | last_step->key= je->s.c_str; |
| 1987 | do |
| 1988 | { |
| 1989 | last_step->key_end= je->s.c_str; |
| 1990 | } while (json_read_keyname_chr(je) == 0); |
| 1991 | if (je->s.error) |
| 1992 | return 1; |
| 1993 | /* Now we have je.state == JST_VALUE, so let's handle it. */ |
| 1994 | |
| 1995 | /* fall through */ |
| 1996 | case JST_VALUE: |
| 1997 | if (json_read_value(je)) |
| 1998 | return 1; |
| 1999 | return 0; |
no test coverage detected