GithubHelp home page GithubHelp logo

gson-flatten's People

Contributors

raja-baz avatar souvikhazra1 avatar tishka17 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

gson-flatten's Issues

Flatten objects in array

Would it be possible to flatten objects in arrays? I am trying to parse the following data structure which has some unnecessary object nesting:

{
"content": {
    "children": [
        {
            "section": {
                "attrs": { ... },
                "children": [ ... ]
            },
        ...
        }
    ]
}

I would like to get rid of the unnecessary section object and flatten it into a children object like so:

{
"content": {
    "children": [
        {
            "attrs": { ... },
            "children": [ ... ]
        },
        ...
    ]
}

Автоматическое имя в json

Поддержка в Flatten формата вида @Flatten("obj::") без указания последнего значения
Пример, такой json

{
  "temperature": {
     "min": -273,
     "max": 1000
  }
}

Должен конвертироваться в объект типа

class Weather {
  @Flatten("temperature::")
  int min;
  @Flatten("temperature::")
  int max;
}

Cannot find library using mavenCentral()

Hi, I have a problem with using your library with mavenCentral(). I have to migrate from jcenter due to JCenter sunset.
Your library is only available on JCenter? Can you push it to mavenCentral?
Could not find org.itishka.gson-flatten:gson-flatten:0.8.1.

Тесты

Разные типы:

  • int
  • Float
  • String
  • Свои классы
  • Свои классы с кастомным парсером
  • Свои классы с Flatten полем

Значения:

  • null объект
  • отсутствующий объект в json
  • отсутствующее поле в json
  • несколько уровней вложения
  • несколько уровней с null на не первом
  • неверный тип поля
  • совпадающие поля во вложенном объекте и свои

Поддержка различных имен поля

Поддерживать как аннотацию @SerializedName, так и установленный в gson FieldNamingPolicy.
Например, должен корректно работать код

class Weather {
    @Flatten("temp::min")
    int minTemp;

    @Flatten("temp::max")
    @SerializedName("qwerty")
    int maxTemp
}

boolean com.google.gson.JsonElement.isJsonObject()' on a null object reference

Hi guys, so i have code like this

public class Parent {
      //@Flatten("data::some_object::field")
      private String fieldName;
}

public class Child extends Parent{
     @Flatten("data::field")
     private String anotherField;
}

so the JSON i received when quering for child staff

{
	"data":{
		"field": "field value"
	}
}

The moment i uncomment the annotation on Parant the app stops working with the error

Process: net.innoflash.his_word, PID: 30475
    java.lang.NullPointerException: Attempt to invoke virtual method 'boolean com.google.gson.JsonElement.isJsonObject()' on a null object reference

Looks like because we do not have that field with nested results, how can i deal with such.
I saw something like this:
@SerializedName(value="name1", alternate={"name2", "name3"}) String b;

it looks like we do not have the alternate param in @Flatten if that will help the situation

Thanks

Not very effective?

Just noticed that you commented on noties/Flatten#1 (comment) and want to ask you why do you think your implementation is not very effective ?

Any particular reason why not submitting a pull request to the other project instead of creating a new project ?

This looks awesome by the way :)

Автоматическое свертывание вложенного объекта

Поддерживать аннотацию @FlattenField("path") и @FlattenField("path", "prefix") для сворачивания всех полей вложенного объекта в соответствующие поля текущего. Пример,

{
  "data": {
     "temp": {
       "min": -273,
       "max": 1000
     }
  }
}
@FlattenField("data::temp")
class Weather {
   int min;
   int max;
}

@FlattenField("data::temp", "temp")
class Weather2 {
   int tempMin;
   int tempMax;
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.