0

I have a problem with sending my JSON object via angularjs' $http.put method.

When I used to send JSON containing only String there was no problem, but now I want to send ints and one int array and I can't get them matched(java class that is going to be mapped with JSON).

    $scope.edit = function(game, goalScorersHome, goalScorersAway) {
  var JSONScore = {
    'id' : game.id,
    'idHome' : game.homeId,
    'idAway' : game.awayId,
    'goalsHome' : game.goalsHome,
    'goalsAway' : game.goalsAway,
    'goalScorers' : []
  };

  for(i=0;i < goalScorersHome.length; i++) {
    JSONScore.goalScorers.push(goalScorersHome[i].id);
  }

  for(i=0;i < goalScorersAway.length; i++) {
    JSONScore.goalScorers.push(goalScorersAway[i].id);
  }

  $log.log(JSONScore);

  fixturesService.editScore(game.id, game.homeId, game.awayId, JSONScore);

This is where I send my JSON. 'Goalscorers' has to be long[] type. And on the REST Server I have class(Score.java) with

  private int id;
  private int goalsHome;
  private int goalsAway;
  private int idHome;
  private int idAway;
  private long[] goalScorersId;

So when I send it I have this message given: PUT http://localhost:9000/push-server/rest/season/1/1/2 500 (Internal Server Error)angular.js:8495 (anonymous function). I'm only asking for help how to map this JSON object(JSONScore to java class. When I pass Strings it works!! This is how this JSON looks like JSONScore image

2
  • this problem:org.codehaus.jackson.map.exc.UnrecognizedPropertyException: Unrecognized field " goalScorers" (Class pl.bpl.push.server.json.Score), not marked as ignorable| at [Source: HttpInputOverHTTP@6b01fc0f; line: 1, column: 74] (through reference cha in: pl.bpl.push.server.json.Score["goalScorers"]) Commented Feb 3, 2015 at 2:11
  • ok, goalScorers vs GoalScorersId... No question. I don't know how to delete. Commented Feb 3, 2015 at 2:23

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.