Giter Club home page Giter Club logo

Comments (6)

kc1116 avatar kc1116 commented on June 26, 2024

How do I use multiple context in my jsonLD objects?

from json-gold.

kazarena avatar kazarena commented on June 26, 2024

@khalilclaybon, you can pass multiple contexts as []interface{} where elements of this array are either strings (for URIs) or map[string]interface{} for context JSON.

Stan

from json-gold.

kc1116 avatar kc1116 commented on June 26, 2024
{
  "@context": [
    "https://w3id.org/identity/v1",
    "https://w3id.org/security/v1"
  ],
  "id": "http://example.gov/credentials/3732",
  "type": ["Credential", "ProofOfAgeCredential"],
  "issuer": "https://dmv.example.gov",
  "issued": "2010-01-01",
  "claim": {
    "id": "did:ebfeb1f712ebc6f1c276e12ec21",
    "ageOver": 21
  },
  "signature": {
    "type": "LinkedDataSignature2015",
    "created": "2016-06-18T21:10:38Z",
    "creator": "https://example.com/jdoe/keys/1",
    "domain": "json-ld.org",
    "nonce": "6165d7e8",
    "signatureValue": "g4j9UrpHM4/uu32NlTw0HDaSaYF2sykskfuByD7UbuqEcJIKa+IoLJLrLjqDnMz0adwpBCHWaqqpnd47r0NKZbnJarGYrBFcRTwPQSeqGwac8E2SqjylTBbSGwKZkprEXTywyV7gILlC8a+naA7lBRi4y29FtcUJBTFQq4R5XzI="
  }
}

If you look at this verifiable claim in JSON-LD format, notice the multiple @context and type properties.. How would I represent this in your golang jsonld syntax. I can not figure it out. @kazarena

from json-gold.

kc1116 avatar kc1116 commented on June 26, 2024

Figured it out with your tip thanks.

doc := map[string]interface{}{
        "@context": []interface{}{
            "https://w3id.org/identity/v1",
            "https://w3id.org/security/v1",
        },
        "id":     "http://example.gov/credentials/3732",
        "type":   []interface{}{"Credential", "ProofOfAgeCredential"},
        "issuer": "https://dmv.example.gov",
        "issued": "2010-01-01",
        "claim": map[string]interface{}{
            "id":      "did:ebfeb1f712ebc6f1c276e12ec21",
            "ageOver": 21,
        },
        "signature": map[string]interface{}{
            "type":           "LinkedDataSignature2015",
            "created":        "2016-06-18T21:10:38Z",
            "creator":        "https://example.com/jdoe/keys/1",
            "domain":         "json-ld.org",
            "nonce":          "6165d7e8",
            "signatureValue": "g4j9UrpHM4/uu32NlTw0HDaSaYF2sykskfuByD7UbuqEcJIKa+IoLJLrLjqDnMz0adwpBCHWaqqpnd47r0NKZbnJarGYrBFcRTwPQSeqGwac8E2SqjylTBbSGwKZkprEXTywyV7gILlC8a+naA7lBRi4y29FtcUJBTFQq4R5XzI=",
        },
    }

    expanded, err = proc.Expand(doc, options)
    if err != nil {
        panic(err)
    }

    ld.PrintDocument("JSON-LD target expansion succeeded", expanded)
    log.Println("\n\n\n")

from json-gold.

kazarena avatar kazarena commented on June 26, 2024

@kc1116, ok that's good. By the way, I'm planning to support LinkedDataSignature2015 out of the box with this library, just didn't have a chance to do it yet.

from json-gold.

johnptoohey avatar johnptoohey commented on June 26, 2024

@kc1116 Have you found a solution to generating signatures for Verified Claims using Go?

from json-gold.

Related Issues (13)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.