-
Notifications
You must be signed in to change notification settings - Fork 31
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
NPE during transformation #22
Comments
Thanks for using sjson. I will have a look at the earliest and let u know. I don't have the source code right now .. give me some time .. will get back. |
I think the reason you're getting NPE is because you missed out specifying @BeanInfo in the classes. I changed your class by doing the same and also changing the annotation @JsonProperty to what sjson supports (you had specified @JsonProperty, which is possibly something you implemented. Anyway here's the stuff that runs fine .. @BeanInfo
} @BeanInfo and the test case .. val r = new NavigationCategoryResource val s = new NavigationCategory let me know if this works .. I am closing the issue right now. Will reopen is required .. |
Hi there ..
am facing a NPE and actually have no idea how to fix it.
My environment:
Scala: 2.8.1
sjson: 2.8.1_0.8
The exception:
java.lang.NullPointerException
at sjson.json.JsBean$$anonfun$3.apply(JsBean.scala:287)
at sjson.json.JsBean$$anonfun$3.apply(JsBean.scala:285)
at scala.collection.TraversableLike$$anonfun$map$1.apply(TraversableLike.scala:206)
at scala.collection.TraversableLike$$anonfun$map$1.apply(TraversableLike.scala:206)
at scala.collection.IndexedSeqOptimized$class.foreach(IndexedSeqOptimized.scala:34)
at scala.collection.mutable.ArrayOps.foreach(ArrayOps.scala:35)
at scala.collection.TraversableLike$class.map(TraversableLike.scala:206)
at scala.collection.mutable.ArrayOps.map(ArrayOps.scala:35)
at sjson.json.JsBean$class.toJSON(JsBean.scala:285)
at sjson.json.Serializer$SJSON$.toJSON(Serializer.scala:112)
at sjson.json.Serializer$SJSON$class.out(Serializer.scala:38)
at sjson.json.Serializer$SJSON$.out(Serializer.scala:112)
at de.liventy.xfunds.ws.ResourcesUtil$class.serializeAsJSON(ProfileResource.scala:27)
at de.liventy.xfunds.ws.ShopResource.serializeAsJSON(ShopResource.scala:21)
The underlying classes:
trait ResourcesUtil {
def serializeAsJSON(obj: AnyRef): String = new String(Serializer.SJSON.out(obj))
def deserializeJSON[T](json: Array[Byte])(implicit m: Manifest[T]): AnyRef =
Serializer.SJSON.inT(m)
}
@JsonIgnoreProperties(Array("navigationcategory.sushiBarSourceCategoryId"))
class NavigationCategory {
@JsonProperty("navigationcategory.hasSubCategory") var hasSubCategory: Boolean = _
@JsonProperty("navigationcategory.navigationCategoryId") var id: Long = _
@JsonProperty("navigationcategory.overNavigationCategoryId") var overId: Long = _
@JsonProperty("navigationcategory.navigationCategoryNavisionId") var navisionId: Long = _
@JsonProperty("navigationcategory.navigationCategoryName") var name: String = _
@JsonProperty("navigationcategory.totalNumberOfProducts") var totalNumberOfProducts: Long = _
var resources:List[NavigationCategoryResource] = _
def setHasSubCategory(b:String){
hasSubCategory= if (b.equals("true")){true} else {false}
}
def setResources(jl:java.util.List[NavigationCategoryResource]){
resources = jl.toList
}
}
class NavigationCategoryResource{
@JsonProperty("resource.fileUrl") var fileUrl: String = _
@JsonProperty("resource.link") var link: String = _
@JsonProperty("resource.logicalCode") var logicalCode: String = _
}
Any hint or help is appreciated ...
The text was updated successfully, but these errors were encountered: