Coder Social home page Coder Social logo

Comments (18)

RicoSuter avatar RicoSuter commented on August 14, 2024

Try

var schema = JsonSchema4.FromJson(File.ReadAllText(...));

from njsonschema.

vmaramreddy1 avatar vmaramreddy1 commented on August 14, 2024

I thought it will just read the plain json text instead of schema . I will check and get back to you then .
Thanks for your quick help.

from njsonschema.

khairnarnitin avatar khairnarnitin commented on August 14, 2024

Hi Rico Suter,
Somehow this feature is not working for me with the version 1.22.5836.1197. I have created two sample json files stored in C:\Test folder as below.
C:\Test\Person.json
{
"type": "object",
"properties": {
"name": { "type": "string" },
"addresses": {
"type": "array",
"items": { "$ref": "address.json" }
}
}
}
C:\Test\address.json
{
"type": "object",
"properties": {
"street": {"type": "string"},
"city": {"type": "string"}
}
}
then I have created one sample tests as below.
var schema = JsonSchema4.FromJson(File.ReadAllText(@"c:\test\person.json"));
var data = JToken.Parse(File.ReadAllText(@"c:\test\data.json"));
var errors = schema.Validate(data);
First line throws exception
An unhandled exception of type 'System.NotSupportedException' occurred in NJsonSchema.dll
Additional information: Could not resolve the path 'address.json' because JSON file references are not supported.
Am I doing something wrong?. Please look into it.

from njsonschema.

RicoSuter avatar RicoSuter commented on August 14, 2024

I think file references are not supported yet. I have to check the code tomorrow if there's an easy way to do this...

from njsonschema.

khairnarnitin avatar khairnarnitin commented on August 14, 2024

Okay, thanks for quick reply. It will be great help since it is part of Draft 4 Schema specs & we cant have large schema files.

from njsonschema.

RicoSuter avatar RicoSuter commented on August 14, 2024

Ok, its fixed now in 1.23, please try again

from njsonschema.

khairnarnitin avatar khairnarnitin commented on August 14, 2024

Thanks. I will try with the latest 1.24 version. Does it supports web references?

from njsonschema.

RicoSuter avatar RicoSuter commented on August 14, 2024

No, not yet. But i can add this too...

from njsonschema.

RicoSuter avatar RicoSuter commented on August 14, 2024

Do you mean an absolute web references which starts either with "http" or "https"?

from njsonschema.

khairnarnitin avatar khairnarnitin commented on August 14, 2024

Okay thanks for quick reply :).
Yes exactly.

from njsonschema.

khairnarnitin avatar khairnarnitin commented on August 14, 2024

Tried with same sample using 1.24 but it is throwing exception
Could not resolve the path 'address.json' because no root path is available.

from njsonschema.

RicoSuter avatar RicoSuter commented on August 14, 2024

You need to load it using the new method JsonSchema4.FromFile()

from njsonschema.

RicoSuter avatar RicoSuter commented on August 14, 2024

... otherwise the file path is not known by the parser (as stated by the exception).

from njsonschema.

khairnarnitin avatar khairnarnitin commented on August 14, 2024

Yes... sorry my bad.. tried with FromFile(), it is working.
Cheers!!!

from njsonschema.

RicoSuter avatar RicoSuter commented on August 14, 2024

v1.25 now supports now supports URL references...

from njsonschema.

khairnarnitin avatar khairnarnitin commented on August 14, 2024

Thanks it is working.

from njsonschema.

khairnarnitin avatar khairnarnitin commented on August 14, 2024

have you provided any class for n/w proxy settings?

from njsonschema.

RicoSuter avatar RicoSuter commented on August 14, 2024

sorry, I don't understand your question?

from njsonschema.

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.