export the Deck object to json-ready format
355831
def to_json(self) -> dict:
        ''''''

        d = self.__dict__
        d['p2th_wif'] = self.p2th_wif
        return d
500323
def to_json(self):
        """"""
        return {
            'network': self.network,
            'state': self.state,
            'nodes': self.node_indices,
            'cut': self.cut,
        }
1163014
def do_json(self):
        """"""
        # Default to listing probes.
        if (self._args.probes, self._args.targets, self._args.boards) == (False, False, False):
            self._args.probes = True
        
        # Create a session with no device so we load any config.
        session = Session(None,
                            project_dir=self._args.project_dir,
                            config_file=self._args.config,
                            no_config=self._args.no_config,
                            pack=self._args.pack,
                            **convert_session_options(self._args.options)
                            )
        
        if self._args.probes:
            obj = ListGenerator.list_probes()
            print(json.dumps(obj, indent=4))
        elif self._args.targets:
            # Create targets from provided CMSIS pack.
            if ('pack' in session.options) and (session.options['pack'] is not None):
                pack_target.PackTargets.populate_targets_from_pack(session.options['pack'])

            obj = ListGenerator.list_targets()
            print(json.dumps(obj, indent=4))
        elif self._args.boards:
            obj = ListGenerator.list_boards()
            print(json.dumps(obj, indent=4))
1295802
def dump_as_json(record, output_file):
    
    def default_func(value):
        """
        Default conversion for JSON value.
        """
        if isinstance(value, frozenset):
            return sorted(value)
        raise TypeError(repr(value) + " is not JSON serializable")

    converted_record = record._replace(
        ordered_statistics=[x._asdict() for x in record.ordered_statistics])
    json.dump(
        converted_record._asdict(), output_file,
        default=default_func, ensure_ascii=False)
    output_file.write(os.linesep)
57763
function toJSON() {
    var s = this;
    var values = Object.assign({}, s.schema);
    Object.keys(values).forEach(function (key) {
      var isFunc = iftype.isFunction(values[key]);

      if (isFunc) {
        delete values[key];
      }
    });
    return values;
  }
213362
def export_to_json(self):
        

        return {
            hostname: sorted(self._encode_key(key) for key in pins)
            for hostname, pins in self._storage.items()
        }
212739
def to_json(*args)
      rows = []
      self.each_row do |row|
        rows.push(row.to_hash)
      end
      rows.to_json
    end
1255277
def parse_deckspawn_metainfo(protobuf: bytes, version: int) -> dict:
    ''''''

    deck = DeckSpawnProto()
    deck.ParseFromString(protobuf)

    error = {"error": "Deck ({deck}) metainfo incomplete, deck must have a name.".format(deck=deck.name)}

    if deck.name == "":
        raise InvalidDeckMetainfo(error)

    if deck.version != version:
        raise InvalidDeckVersion({"error", "Deck version mismatch."})

    return {
        "version": deck.version,
        "name": deck.name,
        "issue_mode": deck.issue_mode,
        "number_of_decimals": deck.number_of_decimals,
        "asset_specific_data": deck.asset_specific_data
        }
40810
def to_json(options = {})
      options.reverse_merge!({ :root => Rabl.configuration.include_json_root })
      result = to_dumpable(options)
      format_json(result)
    end
653670
def json(self):
        """"""
        return {
            "id": self.ID,
            "steps": self.steps,
            "graph_source": self.source,
            "errored": self.errored
        }
987647
public function toJson() {
		$instanceArray['name'] = $this->name;
		$instanceArray['class'] = $this->getClassName();
		$instanceArray['anonymous'] = $this->isAnonymous();
		$instanceArray['type'] = $this->getType();
		
		if ($instanceArray['type'] == self::TYPE_DECLARATIVE) {
			$classDescriptor = $this->getClassDescriptor();
			
			$instanceArray['constructorArguments'] = array();
			foreach ($classDescriptor->getInjectablePropertiesByConstructor() as $propertyName=>$moufProperty) {
				$instanceArray['constructorArguments'][$propertyName] = $this->getConstructorArgumentProperty($propertyName)->toJson();
			}
	
			$instanceArray['properties'] = array();
			foreach ($classDescriptor->getInjectablePropertiesByPublicProperty() as $propertyName=>$moufProperty) {
				$instanceArray['properties'][$propertyName] = $this->getPublicFieldProperty($propertyName)->toJson();
			}
			
			$instanceArray['setters'] = array();
			foreach ($classDescriptor->getInjectablePropertiesBySetter() as $propertyName=>$moufProperty) {
				$instanceArray['setters'][$propertyName] = $this->getSetterProperty($propertyName)->toJson();
			}
			
			// Now, let's search for properties that would be declared in the configuration but that
			// would not exist in the code (this can happen if the property has been renamed in the code)
			$definedPublicProperties = $this->moufManager->getParameterNames($this->name);
			if ($definedPublicProperties) {
				$missingPublicProperties = array_diff($definedPublicProperties, array_keys($instanceArray['properties']));
				foreach ($missingPublicProperties as $missingPublicPropertyName) {
					$instanceArray['properties'][$missingPublicPropertyName] = [
						'warning' => "The public property '".$missingPublicPropertyName."' is declared but does not exist. It is likely it once existed but was renamed or removed.",
						'orphan' => true,
						'type' => null,
						'value' => null,
						'isset' => true,
						'origin' => null,
						'metadata' => null
					];
				}
			}
			
			$definedSetters = $this->moufManager->getParameterNamesForSetter($this->name);
			if ($definedSetters) {
				$missingSetters = array_diff($definedSetters, array_keys($instanceArray['setters']));
				foreach ($missingSetters as $missingSetterName) {
					$instanceArray['setters'][$missingSetterName] = [
					'warning' => "The setter '".$missingSetterName."' is declared but does not exist. It is likely it once existed but was renamed or removed.",
					'orphan' => true,
					'type' => null,
					'value' => null,
					'isset' => true,
					'origin' => null,
					'metadata' => null
					];
				}
			}
				
			$definedConstructorArguments = $this->moufManager->getParameterNamesForConstructor($this->name);
			if ($definedConstructorArguments) {
				$constructor = $classDescriptor->getConstructor();
				if ($constructor) {
					$nbParameters = $classDescriptor->getConstructor()->getNumberOfParameters();
				} else {
					$nbParameters = 0;
				}
				$missingConstructorArguments = array_filter($definedConstructorArguments, function($nb) use ($nbParameters) { return $nbParameters <= $nb; });
				foreach ($missingConstructorArguments as $missingConstructorArgument) {
					$instanceArray['constructorArguments'][$missingConstructorArgument] = [
					'warning' => "The constructor argument n°'".$missingConstructorArgument."' is declared but does not exist. It is likely it once existed but was removed.",
					'orphan' => true,
					'type' => null,
					'value' => null,
					'isset' => true,
					'origin' => null,
					'metadata' => null
					];
				}
			}
			
		} else {
			$instanceArray['code'] = $this->getCode();
		}
		
		return $instanceArray;
	}
1167067
def export_as_json(self):
        
        result = {
            "subscription": self.subscription,
        }

        if self.name:
            result["name"] = self.name

        if self.ask is not None:
            result["ask"] = self.ask

        if self.approved:
            result["approved"] = self.approved

        if self.groups:
            result["groups"] = sorted(self.groups)

        return result
493086
def to_json(template, clean_up=False):
    

    data = load_yaml(template)

    if clean_up:
        data = clean(data)

    return dump_json(data)
563904
def export_net_json(net, net_type, indent='no-indent'):
  '''  '''
  import json
  from copy import deepcopy

  if net_type == 'dat':
    exp_dict = deepcopy(net.dat)

    if type(exp_dict['mat']) is not list:
      exp_dict['mat'] = exp_dict['mat'].tolist()
      if 'mat_orig' in exp_dict:
        exp_dict['mat_orig'] = exp_dict['mat_orig'].tolist()

  elif net_type == 'viz':
    exp_dict = net.viz

  elif net_type == 'sim_row':
    exp_dict = net.sim['row']

  elif net_type == 'sim_col':
    exp_dict = net.sim['col']

  # make json
  if indent == 'indent':
    exp_json = json.dumps(exp_dict, indent=2)
  else:
    exp_json = json.dumps(exp_dict)

  return exp_json
410804
def generate_json_artifacts(app, pagename, templatename, context, doctree):
    
    try:
        # We need to get the output directory where the docs are built
        # _build/json.
        build_json = os.path.abspath(
            os.path.join(app.outdir, '..', 'json')
        )
        outjson = os.path.join(build_json, pagename + '.fjson')
        outdir = os.path.dirname(outjson)
        if not os.path.exists(outdir):
            os.makedirs(outdir)
        with open(outjson, 'w+') as json_file:
            to_context = {
                key: context.get(key, '')
                for key in KEYS
            }
            json.dump(to_context, json_file, indent=4)
    except TypeError:
        log.exception(
            'Fail to encode JSON for page {page}'.format(page=outjson)
        )
    except IOError:
        log.exception(
            'Fail to save JSON output for page {page}'.format(page=outjson)
        )
    except Exception as e:
        log.exception(
            'Failure in JSON search dump for page {page}'.format(page=outjson)
        )
522561
def ToJson(self):
        
        jsn = super(PublishTransaction, self).ToJson()
        jsn['contract'] = {}
        jsn['contract']['code'] = self.Code.ToJson()
        jsn['contract']['needstorage'] = self.NeedStorage
        jsn['contract']['name'] = self.Name.decode('utf-8')
        jsn['contract']['version'] = self.CodeVersion.decode('utf-8')
        jsn['contract']['author'] = self.Author.decode('utf-8')
        jsn['contract']['email'] = self.Email.decode('utf-8')
        jsn['contract']['description'] = self.Description.decode('utf-8')
        return jsn
99965
def render_template_directory(deck, arguments):
    """"""
    output_directory = dir_name_from_title(deck.title)

    if os.path.exists(output_directory):
        if sys.stdout.isatty():
            if ask(
                '%s already exists, shall I delete it?' % output_directory,
                arguments.get('--noinput')
            ):
                shutil.rmtree(output_directory)
        else:
            shutil.rmtree(output_directory)

    # copy support files to output directory
    template_directory_path = (
        '%s/templates/%s' %
        (remarkable.__path__[0], deck.presentation_type)
    )
    shutil.copytree(
        template_directory_path,
        output_directory,
    )

    # copy resources
    if os.path.exists('resources'):
        log.info('Copying resources')
        shutil.copytree('resources', '%s/resources' % output_directory)
    else:
        log.info('No resources to copy')

    # render template
    template_filename = '%s/index.html' % deck.presentation_type
    html = render_template(template_filename, deck.json)

    # write index to output directory
    index_filename = '%s/index.html' % output_directory
    write_file(index_filename, html)

    return output_directory