# Sugar Json example?

**URL:** https://talk.remobjects.com/t/sugar-json-example/9675
**Category:** Elements RTL
**Created:** [June 11, 2016, 1:05am UTC](https://talk.remobjects.com/t/sugar-json-example/9675 "2016-06-11T01:05:49Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![contoso](https://talk.remobjects.com/letter_avatar_proxy/v4/letter/c/5f9b8f/32.png) [@contoso](https://talk.remobjects.com/u/contoso)
#### Post date: [June 11, 2016, 1:05am UTC](https://talk.remobjects.com/t/sugar-json-example/9675/1 "2016-06-11T01:05:49Z")

</div>

Hello?

I downloaded latest beta and add references with “sugar, sugar.data”

in github test example of json, they references sugar.data.JSON

however, in my ide, it says there is no such thing…

i think sugar on github and the one ships with beta are different.

should i download github version? or should i stick to off the shelf shipped version?

if the shipped version is latest one, can i have a example for JSON features?

thank you.

---

<div class="post-metadata">

### Author: ![mh](https://talk.remobjects.com/user_avatar/talk.remobjects.com/mh/32/18050_2.png) [@mh](https://talk.remobjects.com/u/mh)
#### Post date: [June 12, 2016, 1:31am UTC](https://talk.remobjects.com/t/sugar-json-example/9675/2 "2016-06-12T01:31:55Z")

</div>

It’s Sugar.Json, not Sugar.Data.Json.

---

<div class="post-metadata">

### Author: ![mh](https://talk.remobjects.com/user_avatar/talk.remobjects.com/mh/32/18050_2.png) [@mh](https://talk.remobjects.com/u/mh)
#### Post date: [June 12, 2016, 1:37am UTC](https://talk.remobjects.com/t/sugar-json-example/9675/3 "2016-06-12T01:37:09Z")

</div>

Here’s a sample snippet from [my Curaçao Weather app](http://www.curacaoweatherreport.com/2016/06/01/introducing-the-official-curacao-weather-app/). The code in question is used on .NET, iOS and Android:

```auto
import Sugar.Json

public class SummaryData: WeatherData {
	public var Condition: String?
	public var Temperature: Double?
	public var HeatIndex: Double?
        ....
	public var WarningEnglish: String?
	public var WeatherSummaryTextEnglish: String?
        ....

	init(json: JsonNode) {
		super.init(json: json)
		Condition = json["Condition"]?.StringValue
		Temperature = json["Temperature"]?.FloatValue
		HeatIndex = json["HeatIndex"]?.FloatValue

		if let details = json["Details"] as? JsonObject, english = details["English"] as? JsonObject {
			WarningEnglish = english["Warning"]?.StringValue
			WeatherSummaryTextEnglish = english["Weather"]?.StringValue
                        ....
		}
	}
	
	override func ToJson() -> JsonDocument {
		let result = JsonDocument()
		result.Root["Condition"] = JsonStringValue.Create(Condition)
		result.Root["Temperature"] = JsonFloatValue.Create(Temperature)
		result.Root["HeatIndex"] = JsonFloatValue.Create(HeatIndex)
		
		let textsEnglish = JsonObject()
		result.Root["Details"] = JsonObject()
		result.Root["Details"]!["English"] = textsEnglish
		
		if let WarningEnglish = WarningEnglish, WarningColor = WarningColor {
			textsEnglish["Code\(WarningColor)"] = JsonStringValue(WarningEnglish) // legacy, remove
			textsEnglish["Warning"] = JsonStringValue(WarningEnglish)
			textsEnglish["WarningColor"] = JsonStringValue(WarningColor)
		}
		if let WeatherSummaryTextEnglish = WeatherSummaryTextEnglish {
			textsEnglish["Weather"] = JsonStringValue(WeatherSummaryTextEnglish)
		}
                ...
		return result
	}
}

```

hth.

---

<div class="post-metadata">

### Author: ![contoso](https://talk.remobjects.com/letter_avatar_proxy/v4/letter/c/5f9b8f/32.png) [@contoso](https://talk.remobjects.com/u/contoso)
#### Post date: [June 14, 2016, 6:21am UTC](https://talk.remobjects.com/t/sugar-json-example/9675/4 "2016-06-14T06:21:11Z")

</div>

Wow thank you.

It is nice to see the some of code of Curaçao weather app 😃
