• Post Reply Bookmark Topic Watch Topic
  • New Topic

Restful Service - JSON externalId in response not represented as string  RSS feed

 
Greg Belyea
Greenhorn
Posts: 27
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

i am using Netbeans and have built a rest webservice that returns JSON and i am seeing something that looks odd to me... in my response object the externalid field has no quotes but in the model that is being converted here it is a string...

"apiName":"Test Case","duration":7644,"externalId":1234561019

if the externalId field has a letter in it, it comes up with quotes, but why is it treating the field like a number just because it happens to be a valid one when i have declared it a string?

Should have mentioned my maven imports are the following

<dependency>
<groupId>org.codehaus.jackson</groupId>
<artifactId>jackson-mapper-asl</artifactId>
<version>1.9.10</version>
</dependency>
<dependency>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
<version>20140107</version>
</dependency>

Thanks for any clues
 
Greg Belyea
Greenhorn
Posts: 27
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well i solved it so i thought i would post here in case anyone sees similar issues... The only way i could solve this was by using Jackson and calling the mapper.writeValueAsString(response) and returning the string instead of the object.. that got rid of the implicit cast to number and puts the quotes where they need to be
 
J. Kevin Robbins
Bartender
Posts: 1801
28
Chrome Eclipse IDE Firefox Browser jQuery Linux MySQL Database Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for coming back with the solution. Have a cow.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!