Skip to content

Add exit_obeject() functionality #51

Description

@bogdanCsn

In a nested json, it would be useful to be able to exit an object you have entered - a function that does the opposite of enter_object(). Or perhaps change the functionality of enter_object() so that full / relative paths are supported, for example "." would refer to the top level while ".." would refer to the previous level. Here is some code example:

library(tidyjson)
library(dplyr)


input <- '{
      "name": "Bob",
      "age": 30,
      "social": {
            "married": "yes",
            "kids": "no"
      },
      "work": {
            "title": "engineer",
            "salary": 5000
      } 
}'


output <- input %>% as.tbl_json() %>%
      spread_values(name = jstring("name"),
                    age = jnumber("age")) %>%
      enter_object("social") %>% 
      spread_values(married = jstring("married"),
                    kids = jstring("kids")) %>%
      #### I would need an exit_obeject() here
      enter_object("work") %>%
      spread_values(title = jstring("title"),
                    salary = jnumber("salary"))

No activity

Activity on this issue will appear here.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions