JSON Data compare

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • lclarke
    New User
    • Dec 2011
    • 1

    JSON Data compare

    We are attempting to use BC to compare json formated data, and seem to be needing a blend of text compare and csv/data compare features.

    I could use some pointers to how to coherce BC into matching up the pks (as it does for functions etc when comparing languages.

    Three small sample records are pasted below. In this case mdl_pk is the key we'd like to align on.

    Each record has a pk and we'd like BC to align the comparison by the pk.

    If need be, we can inject a consistently named property to align on (eg RECORD_PK) and could probably arrange for it to be the first property in each record if that would help.

    [
    {
    "mdl_auth_fk": "FA392775595B48C7A0198B3AFB83472D",
    "mdl_id": "EP",
    "mdl_instype_id": "ABC",
    "mdl_order": 5,
    "mdl_pk": "0236C75968424C2290DC5D295E86ABD4",
    "mdl_prs_fk": "8973C2FEE6D34A8D9C7488AF31262EE6",
    "mdl_systype": "XYZ",
    "mdl_title": "This string could be quite long",
    },
    {
    "mdl_auth_fk": "EE0D64533A134FDCA3B2746D4BE15377",
    "mdl_id": "PD",
    "mdl_instype_id": "ABC",
    "mdl_order": 9,
    "mdl_pk": "027C82A698FD4732A9E691C583CCC098",
    "mdl_prs_fk": "8973C2FEE6D34A8D9C7488AF31262EE6",
    "mdl_systype": "XYZ",
    "mdl_title": "This string could be quite long",
    "_mdl_pk_2009": 36
    },
    {
    "mdl_auth_fk": "",
    "mdl_id": "RPT",
    "mdl_instype_id": "ABC",
    "mdl_order": 10,
    "mdl_pk": "06DAD869A9554E418AE426365BFFF775",
    "mdl_prs_fk": "857D1F06BAE24BB3A3CE0D9DBE7DE890",
    "mdl_systype": "XYZ",
    "mdl_title": "This string could be quite long",
    }
    ]
  • Aaron
    Team Scooter
    • Oct 2007
    • 15997

    #2
    Hello,

    The injection strategy may help when used in combination with an Important grammar and Never Align Differences.

    Once injected, make a grammar element that matches on that key and define it as important. Then define all other grammars as unimportant and all other text as unimportant, and disable Ignore Unimportant Differences. This will still treat unimportant text as different (in a blue color). Then, in the Text Compare's Session Settings, Alignment tab, you can enable Never Align Differences (which applies to only Important text).

    I would suggest testing this strategy with some test files created manually if the injection process is sufficiently complicated. Depending on your data, it may still not align as you expect if different blocks have different keys or if the keys are out of order. Both scenarios could cause the key to not align, but the block itself still would without the proper key alignment to "push" things into place.
    Aaron P Scooter Software

    Comment

    Working...