GithubHelp home page GithubHelp logo

Error during deserialization about jsona HOT 6 CLOSED

olosegres avatar olosegres commented on May 26, 2024
Error during deserialization

from jsona.

Comments (6)

olosegres avatar olosegres commented on May 26, 2024

@akadlec
That 'if' added because of the bug, see #17

Earlier, if one entity figured in relationships multiple times, jsona didn't process it's meta & links each time, only ones, but meta may be different

from jsona.

akadlec avatar akadlec commented on May 26, 2024

ok so this bug fix added bug and fix :] I made a autopatch so right now I am safe for now

from jsona.

olosegres avatar olosegres commented on May 26, 2024

@akadlec
Can you provide example of data (json), that causes the error?

from jsona.

mynameistechno avatar mynameistechno commented on May 26, 2024

Hi @olosegres I have this same error. Here is sample json:

var Jsona = require("jsona").Jsona;
const f = new Jsona();

const json = {
  data: {
    type: 'foo',
    id: '1',
    attributes: {
      created: '2018-08-29T10:24:07.831695-07:00',
      modified: '2018-08-29T10:24:07.831726-07:00'
    },
    relationships: {
      distribution_models: {
        data: [
          {
            type: 'distribution_models',
            id: '2'
          },
          {
            type: 'distribution_models',
            id: '1'
          }
        ],
        meta: {
          count: 2
        }
      },
      scan_plans: {
        data: [
          {
            type: 'scan_plans',
            id: '1'
          }
        ],
        meta: {
          count: 1
        }
      },
      guidance: {
        data: null
      },
      children: {
        data: [],
        meta: {
          count: 0
        }
      }
    }
  },
  included: [
    {
      type: 'distribution_channels',
      id: '1',
      attributes: {
        created: '2018-09-05T11:42:54.768966-07:00',
        modified: '2018-09-05T11:42:54.769021-07:00',
        name: 'derpy'
      }
    },
    {
      type: 'distribution_formats',
      id: '1',
      attributes: {
        created: '2018-09-05T11:42:44.240765-07:00',
        modified: '2018-09-05T11:42:44.240807-07:00',
        name: 'baz'
      }
    },
    {
      type: 'distribution_licenses',
      id: '1',
      attributes: {
        created: '2018-09-05T11:42:24.154227-07:00',
        modified: '2018-09-05T11:42:24.154297-07:00',
        name: 'foo bar'
      }
    },
    {
      type: 'distribution_models',
      id: '1',
      attributes: {
        created: '2018-09-05T11:43:42.982340-07:00',
        modified: '2018-09-05T11:43:42.982497-07:00',
        name: 'DM foo',
        intended_recipients: 'dudes'
      },
      relationships: {
        channel: {
          data: {
            type: 'distribution_channels',
            id: '1'
          }
        },
        outbound_licenses: {
          data: [
            {
              type: 'distribution_licenses',
              id: '1'
            }
          ],
          meta: {
            count: 1
          }
        },
        format: {
          data: {
            type: 'distribution_formats',
            id: '1'
          }
        },
        dossier: {
          data: {
            type: 'dossiers',
            id: '1'
          }
        }
      }
    },
    {
      type: 'distribution_models',
      id: '2',
      attributes: {
        created: '2018-09-05T21:04:59.600630-07:00',
        modified: '2018-09-05T21:04:59.600677-07:00',
        name: 'derp2',
        intended_recipients: 'asdf,asd'
      },
      relationships: {
        channel: {
          data: {
            type: 'distribution_channels',
            id: '1'
          }
        },
        outbound_licenses: {
          data: [
            {
              type: 'distribution_licenses',
              id: '1'
            }
          ],
          meta: {
            count: 1
          }
        },
        format: {
          data: {
            type: 'distribution_formats',
            id: '1'
          }
        },
        dossier: {
          data: {
            type: 'dossiers',
            id: '1'
          }
        }
      }
    },
    {
      type: 'scan_plans',
      id: '1',
      attributes: {
        created: '2018-09-05T21:38:29.402500-07:00',
        modified: '2018-09-05T21:38:29.402543-07:00'
      },
      relationships: {
        source_locations: {
          data: [
            {
              type: 'source_locations',
              id: '2'
            },
            {
              type: 'source_locations',
              id: '1'
            }
          ],
          meta: {
            count: 2
          }
        },
        dossier: {
          data: {
            type: 'dossiers',
            id: '1'
          }
        }
      }
    },
    {
      type: 'source_locations',
      id: '1',
      attributes: {
        created: '2018-09-05T21:38:47.154435-07:00',
        modified: '2018-09-05T21:38:47.154477-07:00'
      },
      relationships: {
        scan_plan: {
          data: {
            type: 'scan_plans',
            id: '1'
          }
        }
      }
    },
    {
      type: 'source_locations',
      id: '2',
      attributes: {
        created: '2018-09-05T21:42:42.023320-07:00',
        modified: '2018-09-05T21:42:42.023363-07:00'
      },
      relationships: {
        scan_plan: {
          data: {
            type: 'scan_plans',
            id: '1'
          }
        }
      }
    }
  ]
};

console.log(f.deserialize(json))

image

from jsona.

mynameistechno avatar mynameistechno commented on May 26, 2024

FYI including source_locations is what causes it. If I remove it, it works.

from jsona.

mynameistechno avatar mynameistechno commented on May 26, 2024

Can confirm that downgrading to 1.1.10 fixes the issue for the time being.

from jsona.

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.