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

Serialize dataset #84

Open
MarcAntoine-Arnaud opened this issue Nov 22, 2024 · 0 comments
Open

Serialize dataset #84

MarcAntoine-Arnaud opened this issue Nov 22, 2024 · 0 comments

Comments

@MarcAntoine-Arnaud
Copy link

I try to define a struct with json_ld derive attributes like:

#[derive(linked_data::Serialize)]
#[ld(prefix("ex" = "http://example.org/"))]
#[ld(type = "http://example.org/Bar")]
pub struct WellKnown {
  #[ld("ex:name")]
  version: String,

  #[ld("ex:email")]
  path: String,
}

And I search to serialize an instance of it into a string.

By doing that

  let document = serialize(&WellKnown::new()).unwrap();

  let content = document.with(&()).pretty_print().to_string();

  println!("{content}");

I retrieve something close like (I expect to retrieve a dict, not a list of a dict):

[
  {
    "@type": [
      "http://example.org/Bar"
    ],
    "http://example.org/name": [
      {
        "@value": "1.0"
      }
    ],
    "http://example.org/email": [
      {
        "@value": "/"
      }
    ]
  }
]

A this point I didn't know the way to serialize a dataset itself and not the list.

Can you provide an example of it ?

Best,

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

1 participant