Code Monkey home page Code Monkey logo

Comments (5)

omissis avatar omissis commented on May 28, 2024

Hi @rbellido-ut thanks for reporting this issue, I will look into it!

from go-jsonschema.

omissis avatar omissis commented on May 28, 2024

@rbellido-ut I can't seem to reproduce your error, but I get a different one as time does not get imported correctly. what version of go-jsonschema are you using? Also, can you share the whole generated go file, including imports, please?

from go-jsonschema.

omissis avatar omissis commented on May 28, 2024

I investigated the matter a bit today and it seems the problem is a bit more complex than I expected, as we are dealing with a nullable reference type here, which makes implementing custom unmarshalling the value correctly a bit of a challenge. I will try to see if I can find a solution in the next days, let's see.

from go-jsonschema.

andrewpollock avatar andrewpollock commented on May 28, 2024

Hi,

I think I may have a related problem.

I'm operating on https://csrc.nist.gov/schema/nvd/api/2.0/cve_api_json_2.0.schema, and having invoked it as go-jsonschema -p cves /tmp/cve_api_json_2.0.schema have ended up with this particular struct:

type CveApiJson20Schema struct {
        // Format corresponds to the JSON schema field "format".
        Format string `json:"format" yaml:"format" mapstructure:"format"`

        // ResultsPerPage corresponds to the JSON schema field "resultsPerPage".
        ResultsPerPage int `json:"resultsPerPage" yaml:"resultsPerPage" mapstructure:"resultsPerPage"`

        // StartIndex corresponds to the JSON schema field "startIndex".
        StartIndex int `json:"startIndex" yaml:"startIndex" mapstructure:"startIndex"`

        // Timestamp corresponds to the JSON schema field "timestamp".
        Timestamp time.Time `json:"timestamp" yaml:"timestamp" mapstructure:"timestamp"`

        // TotalResults corresponds to the JSON schema field "totalResults".
        TotalResults int `json:"totalResults" yaml:"totalResults" mapstructure:"totalResults"`

        // Version corresponds to the JSON schema field "version".
        Version string `json:"version" yaml:"version" mapstructure:"version"`

        // NVD feed array of CVE
        Vulnerabilities []CveItem `json:"vulnerabilities" yaml:"vulnerabilities" mapstructure:"vulnerabilities"`
}

A sample of what I'm trying to decode is (see https://services.nvd.nist.gov/rest/json/cves/2.0?cveId=CVE-2023-4863):

{
"resultsPerPage": 1,
"startIndex": 0,
"totalResults": 1,
"format": "NVD_CVE",
"version": "2.0",
"timestamp": "2023-11-21T09:56:39.367",
"vulnerabilities": []
}

Whilst debugging why decoding was failing, I noticed this error:

time.ParseError {Layout: "2006-01-02T15:04:05Z07:00", Value: "2023-11-20T01:00:26.840", LayoutElem: "Z07:00", ValueElem: "", Message: ""}

I've been having some fun decoding the ISO 8601 format the NVD is using (see also https://mastodon.au/@andrewpollock/111447117663929594)

I'm not actually understanding how the time format "2006-01-02T15:04:05Z07:00" is getting arrived at. I know this is the time.RFC3339 constant, but I'm not seeing how things are defaulting to this? I think if I can override this (somewhere) to be "2006-01-02T15:04:05.999" instead, I might be in business...

from go-jsonschema.

Related Issues (20)

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.