Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JSON to arrai object #82

Merged
merged 1 commit into from
Mar 29, 2020
Merged

JSON to arrai object #82

merged 1 commit into from
Mar 29, 2020

Conversation

nofun97
Copy link
Contributor

@nofun97 nofun97 commented Mar 29, 2020

JSON Mapping

Maps JSON values to arrai objects

  • 42 -> 42
  • true/false -> (b: true/false)
  • null -> (null: {})
  • "abc" -> (s: "abc")
  • [1, 2, 3] -> (a: [1, 2, 3])
  • {"a": 42} -> {"a": 42}

Checklist:

  • Added related tests
  • Made corresponding changes to the documentation

this commit creates a function `//.json.decode` which takes a JSON string
and returns an arrai object. Each data type is mapped to an arrai value.

- `123` -> `123`
- `"string value"` -> `(s: "string value")`
- `true`/`false` -> `(b: ({})` / `(b: {})`
- `null` -> `(null: {})`
- `[1, 2, 3]` -> `(a: [1, 2, 3])`
- `{"a": 42, "b": "string"}` -> `{"a": 42, "b": (s: "string")}`
"h": (a: [])
},
"i": (null: {}),
"j": (a: [(b: {()}), (b: {})]),
Copy link
Contributor

@marcelocantos marcelocantos Mar 29, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: You can write true instead of {()} and false instead of {}. They are exactly the same thing, but it conveys the intent better.

@nofun97 nofun97 merged commit 53b734c into arr-ai:master Mar 29, 2020
@nofun97 nofun97 deleted the json-func branch June 2, 2020 23:50
anzopensource pushed a commit that referenced this pull request Apr 23, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants