Can JSON Format support Scene graph? - json

I am attempting to write a STEP loader that converts STEP to the THREE JS JSON format.
However, I have not seen anything in the JSON format information about creating a scene graph - i.e. a hierarchical scene structure.
Is it possible to do so?
Thanks - Imtiaz

If you are writing a Loader, you don't need Three.js JSON format as an intermediate step. As the other loaders do, just create the THREE.Geometry, THREE.Mesh, THREE.Object3D etc objects directly as you go about parsing the STEP file. Object3D is the basic container which you can use to create hierarchies. In addition to being able to contain meshes, you can .add() any number of other Object3Ds into Object3D.
If you still want to have this JSON step, the three JSON model format itself does not have support for hierarchies. But there is also (rather new I believe) Three.js object JSON format, which can store hierarchies. See THREE.ObjectLoader , it is in src/loaders/ObjectLoader.js

Related

How to generate Recordio from Java object

I am trying to serialize a list of java Objects (POJO) into RecordIO format. I have seen this BeanIO (http://beanio.org/) but it seems to be outdated. Is there any other Java library that could be used or a different way to do this ?
Once list of objects is serialized it will be used to train a model with SageMaker.
Solving my own problem. I decided to use Apache Avro instead of BeanIO. Spark allow to serialize using Avro (c.f. Spark-Avro). This seems to work however it did not fit my use case has I was trying to serialize an array of numbers.

Importing a json file into Cassandra

Hi is it possible to import any random json file into cassandra.
The json file is not exported from sstable2json. The json file is from a different website and needs to be imported into cassandra. Please could anyone advise whether this is possible
JSON support won't be introduced until Cassandra 3.0 (see CASSANDRA-7970) and in this case you still need to define a schema for your json data to map to. You do have some other options:
Use maps which sort of map to JSON. Maps can be indexed as of Cassandra 2.1 (CASSANDRA-4511) There is also a good Stack Exchange post about this.
You mention 'any random json file'. You could just have a string column that contains the raw JSON, but then you lose any query-ability of that data.
Come up with some kind of schema for your JSON data and map it to a CQL table and write some code that parses the JSON and writes it to the CQL table mapping to that data. This doesn't sound like an option for you since you want to be able to import any random JSON file.
If you are looking to only do json document storage, you might want to look at more document-oriented solutions instead of a column-oriented solution like cassandra.

Javascript in place of json input step

I am loading data from a mongodb collection to a mysql table through Kettle transformation.
First I extract them using MongodbInput and then I use json input step.
But since json input step has very low performance, I wanted to replace it with a
javacript script.
I am a beginner in Javascript and even though i tried somethings, the kettle javascript script is not recognizing any keywords.
can anyone give me sample code to convert Json data to different columns using javascript?
To solve your problem you need to see three aspects:
Reading from MongoDB
Reading from JSON
Reading from (probably) String
Reading from MongoDB Except if you changed the interface, MongoDB returns not JSON but BSON files (~binary JSON). You need to see the MongoDB documentation about reading and writing BSON: probably something like BSON.to() and BSON.from() but I don't know it by heart.
Reading from JSON Once you have your BSON in JSON format, you can read it using JSON.stringify() which returns a String.
Reading from (probably) String If you want to use the capabilities of JSON (why else would you use JSON?), you also want to use JSON.parse() which returns a JSON object.
My experience is that to send a JSON object from one step to the other, using a String is not a bad idea, i.e. at the end of a JavaScript step, you write your JSON object to a String and at the beginning of the next JavaScript step (can be further down the stream) you parse it back to JSON to work with it.
I hope this answers your question.
PS: writing JavaScript steps requires you to learn JavaScript. You don't have to be a master, but the basics are required. There is no way around it.
you could use the json input step to get the values of this json and put in common rows

save UIObject data in JSON file

how to create and save a UIComponent information in JSON file? I'm using as3corelib but i'm unable to save object on disk in text file.
var encodedObjectString:String = com.adobe.serialization.json.JSON.encode(zorder.getItemAt(0));
Can I save UIObject in JSON text file?
I guess your serialization attempt goes via parent link of your UIObject you want to serialize, and then traverses child list encountering the same UIObject. Stack overflow.
In order to make a manual serialization, you need to serialize only part of your object's fields, excluding any and every link to DisplayObjects of any kind (UIObject class included). For this, perhaps it'll be better if you do a writeExternal() implementation for your object, perform a serialization via ByteArray, then use it as you want. Or, you can have your UIObject have a dedicated "data to serialize" object as property that will get serialized natively, and will only contain data that you want to serialize.
Here is a manual about externalizable objects.

Why should I use JavaScriptObject overlay classes instead of native Java classes when processing JSON data?

In my GWT project I need to process json data retrieved from a database via PHP. I have seen the Google examples using JavaScriptObject overlay classes. What I don't understand is why this seems to be the prefered method of processing the json data. Why shouldn't I use all native Java code to pull in the data?
Think about it the other way around: what does it mean to use POJOs? (or native Java classes as you name them)
You have to:
parse the JSON into some Java-accessible structure (e.g. com.google.gwt.json.client.JSONObject, or elemental.json.JsonObject)
create POJOs
fill the POJOs with the data from the parsed JSON structure
now you can forget the parsed JSON structure from step 1
On the other hand, with JavaScriptObject, you use JsonUtil.safeEval and TA-DA! you get your JSON parsed right into a typed Java object!
Now, to deal with JSON, there's also AutoBeans.
Choose your poison.