JSON Validator Tools

Discussion in 'Mod Discussions' started by sebs303, December 12, 2013.

  1. sebs303

    sebs303 New Member

    Messages:
    22
    Likes Received:
    6
    Hi

    Being a developer and extremely interested in PA I started to use the free time at hand to dev a suite of tools that help validate the current json files against so called JSON-Schema.
    So far it is not only telling of the JSON os valid but as well if any given JSON Struct has exactly the attributes and value types that are required.
    The lib is for javascript and based on node.js. This is stuff that other mod devs can build upon.

    Test it here

    Update II

    • New UI
    • Using a specific JSON Editor to help you with JSON outlines

    Update

    There is a web tool for weapon.json type files now


    However, I have some questions.

    • Are there any original Informations by uber what the exact specs fo a file are
    • How much are these specs stiull changeing?
    • Does uber has an own lib to validate its .json files?
    • What would mod devs like for a tool? Website, Mac/PC App or just a lib that everyone can use?
    • What would wishes be for this lib?
    • What dataset can I work against? Where do I find that on my mac?
    • Are these JSON Datasets, included with PA in a copyright status so that I can add them to an github repo and use them for testing purposes?
    HTML:
    [CODE] var validator = new Validate('weapon');
            var res = validator.validate({
                "base_spec": "/pa/tools/base_shell_turret/base_shell_turret.json",
                "ammo_id": "/pa/units/land/tank_light_laser/tank_light_laser_ammo.json",
                "rate_of_fire": 1,
                "max_range": 100,
                "yaw_rate": 90,
                "pitch_rate": 90,
                "yaw_range": 180,
                "pitch_range": 15,
                "auto_attack": true,
                "target_layers": ["WL_Air", "WL_Land"]
            }, function(err, result) {
                // we dont want a error
                assert.equal(err, null);
                assert.equal(result.valid, true);
                assert.equal(result.errors.length, 0);
                assert.equal(result.warnings.length, 0);
                done();
            });[/CODE]
    Feedback / Suggestions very welcome
    Last edited: January 7, 2014
    cwarner7264 and LavaSnake like this.
  2. LavaSnake

    LavaSnake Post Master General

    Messages:
    1,620
    Likes Received:
    691
    Glad to have you join the ranks of PA modders! I'm guessing it would be most helpful to have a simple web based version (maybe hosted at our PA mods GitHub repo) and a version that can be easily edited for local use.
  3. sebs303

    sebs303 New Member

    Messages:
    22
    Likes Received:
    6
    I will host the stuff myself. Still getting my head around a quasi-complete set of JSON Schemas. However, its on github already
  4. Raevn

    Raevn Moderator Alumni

    Messages:
    4,226
    Likes Received:
    4,324
    Last edited: December 12, 2013
  5. sebs303

    sebs303 New Member

    Messages:
    22
    Likes Received:
    6
    Ic ..... I hope I can find a way to keep this accurate and fit for future versions.
  6. sebs303

    sebs303 New Member

    Messages:
    22
    Likes Received:
    6
    The basic code is there. The app can say OK/NOK to a given json. It only validates weapon.json. Its a minimal thingie. It needs everything. But the basic setup is there. I will add stuff on a daily basis and hopefully, in beginning of 2014, it will be useful to devs.


    http://protected-ravine-6736.herokuapp.com/
  7. sebs303

    sebs303 New Member

    Messages:
    22
    Likes Received:
    6
    there are updates in the original post
    cwarner7264 likes this.
  8. cola_colin

    cola_colin Moderator Alumni

    Messages:
    12,074
    Likes Received:
    16,221
    What I really would like is a simple tool I can run on the PA folder so it processes all json and formats them to be readable. :)
  9. Raevn

    Raevn Moderator Alumni

    Messages:
    4,226
    Likes Received:
    4,324
    cola_colin likes this.
  10. cola_colin

    cola_colin Moderator Alumni

    Messages:
    12,074
    Likes Received:
    16,221
    haha, so that's where I had the idea from.
    Thanks.
  11. sebs303

    sebs303 New Member

    Messages:
    22
    Likes Received:
    6
    I released the underlying js library ... for node.js so far.
  12. sebs303

    sebs303 New Member

    Messages:
    22
    Likes Received:
    6
    And some boilerplate unit json tester online
  13. ORFJackal

    ORFJackal Active Member

    Messages:
    287
    Likes Received:
    248
    I've created a script like this: https://github.com/orfjackal/pa-version-diff
  14. sebs303

    sebs303 New Member

    Messages:
    22
    Likes Received:
    6
    Basic unit.json file support is in the module, but not yet on the webtool version
  15. sebs303

    sebs303 New Member

    Messages:
    22
    Likes Received:
    6
    Bumping the article, there is a new UI

Share This Page