package Batch2
import org.apache.spark.sql.types._
import org.apache.spark.{SparkConf, SparkContext}
import org.apache.spark.sql.{DataFrame, Dataset, SQLContext}
import org.apache.spark.sql.functions._
//三范式(面向对象,面向过程,面向函数)
object JSONAnalysis2 {
def main(args: Array[String]): Unit = {
//conf
val conf = new SparkConf()
.setMaster("local[*]")
.setAppName(this.getClass.getSimpleName)
//sparkcontext
val sc = new SparkContext(conf)
//sqlContext
val sql = new SQLContext(sc)
import sql.implicits._
val dataSet1: Dataset[String] =Seq(
"""
|{
| "devices": {
| "thermostats": {
| "peyiJNo0IldT2YlIVtYaGQ": {
| "device_id": "peyiJNo0IldT2YlIVtYaGQ",
| "locale": "en-US",
| "software_version": "4.0",
| "structure_id": "VqFabWH21nwVyd4RWgJgNb292wa7hG_dUwo2i2SG7j3-BOLY0BA4sw",
| "where_name": "Hallway Upstairs",
| "last_connection": "2016-10-31T23:59:59.000Z",
| "is_online": true,
| "can_cool": true,
| "can_heat": true,
| "is_using_emergency_heat": true,
| "has_fan": true,
| "fan_timer_active": true,
| "fan_timer_timeout": "2016-10-31T23:59:59.000Z",
| "temperature_scale": "F",
| "target_temperature_f": 72,
| "target_temperature_high_f": 80,
| "target_temperature_low_f": 65,
| "eco_temperature_high_f": 80,
| "eco_temperature_low_f": 65,
| "away_temperature_high_f": 80,
| "away_temperature_low_f": 65,
| "hvac_mode": "heat",
| "humidity": 40,
| "hvac_state": "heating",
| "is_locked": true,
| "locked_temp_min_f": 65,
| "locked_temp_max_f": 80
| }
| },
| "
三范式(面向对象,面向过程,面向函数)
最新推荐文章于 2022-01-21 22:26:23 发布