Quantcast
Channel: jQuery Library for SharePoint Web Services
Viewing all articles
Browse latest Browse all 6517

Edited Feature: Add new objectType to SPXmlToJson for text columns containing JSON [10221]

$
0
0
Sometimes we may store JSON as text in a list column. Maybe something like this in a column called PerformanceMetrics:
``` json
{
"competency": "Auto Painting",
"subCompetency": "Dent Repair",
"last12Months": {22, 305, 10, 305, 123, 895, 234, 684, 203, 102, 302, 292}
}
```
To enable better conversion of the text value to JSON in applications, add a new mapping option using objectType: "JSON". By using $.parseJSON, we can convert from the text representation to JavaScript objects.

The conversion function looks like this:

``` javascript
function jsonToJsonObject(s) {
if (s.length === 0) {
return null;
} else {
return $.parseJSON(s);
}
}
```

Viewing all articles
Browse latest Browse all 6517

Trending Articles