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

How to create JSON array? #66

Closed
asm0dey opened this issue May 1, 2024 · 3 comments
Closed

How to create JSON array? #66

asm0dey opened this issue May 1, 2024 · 3 comments

Comments

@asm0dey
Copy link

asm0dey commented May 1, 2024

I thought I might be able to create a JSON array, but whatever I do, it always generates an object with null values for me.

@mgree
Copy link
Owner

mgree commented May 1, 2024

Can you explain what you're trying to do and what you're getting in more detail?

You should be able to do something like the following on Linux:

$ ffs --new foo.json &
$ setfattr -n user.type -v list # use xattr on macOS
$ echo hi >foo/a
$ echo hello >foo/b
$ echo howdy >foo/c
$ umount foo
$ cat foo.json
['hi', 'hello', 'howdy']

(NB I'm not at a computer with ffs installed, so it might not be exactly this way.)

@asm0dey
Copy link
Author

asm0dey commented May 1, 2024

OK, here is my flow:

❯ ffs --new x.json &
[1] 460213
❯ cd x
❯ md a
❯ cd a
❯ md array
❯ echo value1 > key1
❯ echo value2 > key2
❯ cd array
❯ echo > arval1
❯ echo > arval2
❯ md object_in_array
❯ cd object_in_array
❯ echo y > x
❯ cd ../../../../
❯ umount x
[1]  + 460213 done       ffs --new x.json
❯ cat x.json
{"a":{"array":{"arval1":null,"arval2":null,"object_in_array":{"x":"y"}},"key1":"value1","key2":"value2"}}

I'm honestly not sure what I'm doing wrong, probably an object can't be an element of an array? Maybe I have to stick to primitive values?

@asm0dey
Copy link
Author

asm0dey commented May 1, 2024

Oh, I didn't know about setfatr, I'm so sorry!

@asm0dey asm0dey closed this as completed May 1, 2024
mgree added a commit that referenced this issue May 2, 2024
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

No branches or pull requests

2 participants